Alteryx Designer Desktop Discussions

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

Using REGEX to extract string after keyword

SArielle
7 - Meteor

Hello.. 

I am trying to extract a string after 2 different variation of keywords. However the digits to be extracted can vary. 

Any help or suggestions to do this will be very helpful and very much appreciated. 

 

Sample data :

Value
PROG P523205 (22009442) OFFSET WAS UTILIZED BY
PROGRAM P1483107(22009933) FEE OFFSET PARTIALLY
PROGRAM P1341224 (22009904) OFFSET FULLY UTILIZED
PROG P1735249 OFFSET FULLY UTILIZED

 

Expected Results

ValueProgram
PROG P523205 (22009442) OFFSET WAS UTILIZED BYP523205
PROGRAM P1483107(22009933) FEE OFFSET PARTIALLYP1483107
PROGRAM P1341224 (22009904) OFFSET FULLY UTILIZEDP1341224
PROG P1735249 OFFSET FULLY UTILIZEDP1735249
9 REPLIES 9
BRRLL99
11 - Bolide

Please try this formula with this regex configuration

 

regex formula :    (?:PROG|PROGRAM)\s([A-Z0-9]+)

 

 

BRRLL99_0-1685502680361.png

 

SArielle
7 - Meteor

Thanks!!

Can I confirm my understanding of the formula?

 

(?:PROG|PROGRAM) <- this is the conditional pick-up identifier? if I have a 3rd condition, say "PROD" could I use PROG|PROGRAM|PROD?

\s([A-Z0-9]+)<-- A-Z means that any alphabet character + up to 9 numerical will be picked up? If the string was "Program P1341224 2209904 inv ref" would it also end up picking the digit "2" as the 9th numeric?

ShankerV
17 - Castor

Hi @SArielle 

 

One way of doing this even if you have PRG/PROGRAM/PROD etc.

 

ShankerV_0-1685505304716.png

 

ShankerV_1-1685505323596.png

 

(P\d+)

 

Many thanks

Shanker V

SArielle
7 - Meteor

oh so basically the formula can picks up as long as it has that alphabet and numeric behind?

ShankerV
17 - Castor

Hi @SArielle 

 

Yes exactly.

 

However as I saw in your examples shared, the word was P, hence I have used the Regex to find P and all the digits following that.

 

Many thanks

Shanker V

SArielle
7 - Meteor

If I used \d+ would it impact if let's say my program has a mixture of alphabets for example P124569A?

ShankerV
17 - Castor

Hi @SArielle 

 

Using \d+ will help to read only the digits.

 

If you program is mixture of alphabets and digits. Then use the below Regex.

 

(P\d+\u{0,1})

 

ShankerV_0-1685507615056.png

ShankerV_1-1685507635822.png

 

Many thanks

Shanker V

Raj
15 - Aurora

Hope this helps.

 

By using the regular expression pattern ([A-Z]\d+), you can extract the code that starts with any uppercase letter followed by one or more digits.

 

By using the regular expression pattern ([A-Z]\d+\u{0,1}) you can extract the code that starts with any uppercase letter followed by one or more digits followed by alphabet.

SArielle
7 - Meteor

Thank you everyone. This is very helpful and very thankful for the supportive community here.

Labels