community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

REG_EX Formula to pull defined length in string field

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.

 

Screenshot_1.png

 

 

 

Asteroid

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

 

 capture.PNG

 

 

Capture2.PNG

Magnetar
Magnetar

Try the following formula:

Regex_replace([Field1],".*\s([\d]{7})(?:$|[\s]+).*","$1")

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.


Labels