Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Need help with Regex_replace formula

RakeshPalla
5 - Atom

Hello. Could someone please help me in getting Regex_Replace formula only to PO number from text field,

I have randomly values like "Test PO# 123456",  Test 123456 PO, 123456 and i need output as just 123456. Thanks.

3 REPLIES 3
SPetrie
13 - Pulsar

Depending on what the rest of the field looks like, you can replace all non-numeric characters with blanks.

REGEX_Replace([field],"\D", "")

If your PO has dashes or the leading info has unnecessary numbers, we would need to see more examples to help build a more robust pattern.

RakeshPalla
5 - Atom

Hello. Thanks for the response. Yes since the PO field is an open text i do have the values coming with others numbers too. Example "Contractor Request Number 2893 was approved with PO 18607271 for 3000 USD." But i want my output to have only the PO number which is 18607271.

SPetrie
13 - Pulsar

You can try an expression like this to replace the existing string with just the string of numbers found after PO.

REGEX_Replace([test],".*P.?O.*?\D*(\d+).*","$1")

Regex is not my strong point, so someone else may come up with a better one.

It should grab most lines, but it requires PO to come first.

 

regex.PNG

 

Labels
Top Solution Authors