Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
The Expert Exam is now live online! Read about the specifics and what it took to bring it to life in the blog by our very own Elizabeth Bonnell!

REG_EX Formula to pull defined length in string field

6 - Meteoroid

Hello Team,


I'm tryting to retrieve an specific length for digits in a string field, I'm using a Reg_Ex Formula to do this [ Regex_replace([field1],"[^\d]+"," ") ] and I'm getting almost what I need since with the formula I'm retriving only digits from the field however I exactly need to pull only the values with 7 digits only which are separeted by " ". is there any way to this more friendly?


Field 3 should be my desired result.






8 - Asteroid

I would use the RegEx tool and Parse. You would keep RegExOut2 as your results.






14 - Magnetar

Try the following formula:


This will look for any 7 digit value that is prefaced by a space and then immediately preceded by either a space or an end of line character.  The ([\d]{7}) is a marked group, looking specifically for 7 digits, and is also the corresponding "$1" in the "replace value" of the formula.  This leaves us with only the matching number.