This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I am trying to use the RegEx tool to parse data. This is my first time using RegEx, so naturally, everything looks alien to me here. I have a dataset with a column I would like to separate into three columns; a name, a capital letter, and a number. The data currently looks like this:
I read an introduction post to parsing with RegEx, so I get the basics, but I can't figure out why the expression I have included won't parse the way I want it to. At first, I only included an expression to parse out the name: which worked perfectly! Then, I added an expression to parse out the capital letter after the name as well, and now I am only seeing null values. See picture below. Any ideas as to how I should formulate my expression?
The easiest way here is definitely text to columns, like @Ladarthur had, as you have comma separating your data points.
I thought I'd just give you a quick idea of how the regex works though, for your understanding.
Each item in brackets is a separate bit of data to spit out - since we have three sets of brackets we get three outputs.
\w is a letter. The + means more than 1. so you're saying give me more than one letter
we then show that there will be a comma. This is outside the brackets as we don't want to return it
the \u is an uppercase letter. You need to uncheck case insensitive for this to have any impact
same thing with the comma
the \d is a number. The plus again shows that we want more than one.
there's loads of different ways of doing this! :)
Hope this gives you a little bit of an idea. The best place to practice regex is www.regex101.com . This will highlight your text as your going showing exactly what each part of your code is doing. I use it all the time.