Search code examples
regexparsingalteryx

RegEx Parse Tool to extract digits from string


Using Alteryx, I have a field called Address which consists of fields like A32C, GH2X, ABC19E. So basically where digits are pinned between sets of letters. I am trying to use the RegEx tool to extract the digits out into a new column called ADDRESS1.

I have Address set to Field to Parse. Output method Parse. My regular expression is typed in as:

(?:[[alpha]]+)(/d+)(?:[[alpha]]+)

And then I have (/d+) outputting to ADDRESS1. However, when I run this it parses 0 records. What am I doing wrong?


Solution

  • To match a digit, use [0-9] or \d. To match a letter, use [[:alpha:]].

    Use

    [[:alpha:]]+(\d+)[[:alpha:]]+
    

    See the regex demo.