Help me please to create a regex to extract string and number from a string like 906D3829.22 into 906 D 3829.22
So far, I have been able to extract numbers using [\d.]+ into 906 3829.22
Solved! Go to Solution.
This should work for any number/string/number combination: ([\d]+)([[:alpha:]]+)([\d].+)
@kathleenmonks Does that last full stop need to go inside the square brackets?
If you use a formula tool with:
Regex_replace([Field], '(\d+)(\D+)([0-9\.]+)', '$1 $2 $3')
I believe that should give you the output requested above in a single field. Not at my laptop with an Alteryx install to double check this, though.
@DataNath You don't need to escape that full stop / period.
Thanks for the tip @PhilipMannering! Is that always true when including characters you'd normally escape within a group?
@PhilipMannering Good catch. It works as is for this particular case, but the decimal identifies "any single character" so it could result in other characters slipping through. You could change it to: ([\d]+)([[:alpha:]]+)([\d\.]+) to only pick up the decimal.
@DataNath Oooh.. that's a good question. I think that is the case, yes.
Use a regex tool and select the parse mode -- input this in
(\d+)(\D+)(.+)
What this is doing is creating 3 groups
Group 1 - digits up to a non digit char
Group 2 - non-digit character
Group 3 - everything else after group 2
Please make sure to mark a solution!
Thanks