Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Fetching The Data Using RegEx.

shashank_shukla
8 - Asteroid

Hello,

I'm working on a project that requires me to use RegEx to retrieve data.

 

Situation:

The client has a Free Text column, and I need to get the data from there using RegEx based on specified terms.

The position of specific words in the column is not fixed.

I've included an example of the data.

 

InputOutput1output2
The Id contains ProtocolId 1001 and SiteId 200110012001
The Id contains SiteId 2002 and ProtocolId 100110012002
The Id contains ProtocolId 1001 and SiteId 200310012003
The Id contains ProtocolId 1001 and SiteId 200410012004
The Id contains ProtocolId 1001 and SiteId 200510012005

 

Please check and assist me to find the solution.

Please also include a sample workflow if possible.

12 REPLIES 12
DataNath
17 - Castor

Should be able to use this. If there's any drastic variations that may mess this up then let me know and can revisit:

 

 

(\d+)\D+(\d+)

 

 

DataNath_0-1652963284387.png

 

If there'll only ever be 2 groups of numbers you're pulling out, then tokenize is a very safe option to. Using the following will just extract the 2 instances of a group of numbers:

 

DataNath_1-1652963408042.png

 

 

binuacs
20 - Arcturus

@shashank_shukla The RegexTokenize should work on this case

 

binuacs_0-1652963842757.png

 

shashank_shukla
8 - Asteroid

Hello @DataNath ,

 

in my problem I have to fetch the data on the basis of ProtocolId and SiteId words because my column is free text so it taking other Numeric value as output.

Ex:-

Input:- ProtocolId 1001 and SiteId 2001

Output:- 1001 2001

 

 

Can you provide the solution on the basis of words

shashank_shukla
8 - Asteroid

Hello @binuacs ,

 

If possible can you give the solution using the Specific word.

I just gonna try with the specific words approach.

DataNath
17 - Castor

One after the other should do the trick and be specific @shashank_shukla - workbook attached.

 

DataNath_0-1652964557134.png

 

 

shashank_shukla
8 - Asteroid

Hello @binuacs and @DataNath ,

 

For both the approach its taking the first numeric available in Column.

But I want to fetch the data for ProtocolId and SiteId numeric values only.

 

So all the solution which is provided by you is not working in my case.

If possible kindly provide the solution using Specific words only.

DataNath
17 - Castor

@shashank_shukla the new solution I provided just above is correct against your expected outcome and is specific to the words in the right order.

DataNath
17 - Castor

The first RegEx tool extracts the numbers after 'ProtocolId' and ignores other:

 

DataNath_0-1652964910566.png

 

The second then does the same for 'SiteId':

 

DataNath_1-1652964938312.png

 

binuacs
20 - Arcturus

@shashank_shukla Another method without using RegEx

binuacs_0-1652967206020.png

 

Labels