Extracting multiple data using regex based on strings

How would be get the ff using regex ? get string that starts with AT and ends with the number for example AT-210209-141 , AT-210209-421, AT-210209-423 . Also get the string starts with CMTRX like CMTRX00015591 , also starting with PMTRX like PMTRX0003232 and string starting with AONCUR like AONCUR-AP-34334. How do we dynamically do that ? any idea ? thanks.
#DATA

El AT-210209-141 ! General
o AT-210209-421 General 
El AT-210209-421 General 
o AT-210209-423 General 
El AT-210209-423 General
AL CT-210209-423 General
El CMTRX0012323 General 
o CMTRX00053233 General 
El CMTRX00015591 General 
El CMTRX00015591 General 
El PMTRX0001223 General 
El PMTRX0003232 General 
El AONCUR-AP-34334 General 
El AONCUR-AP-4343 General 
El AONCUR-AP-23342 General 
El AMPay00012345 General 
AL L4-210209-423 General
AL TR-210209-423 General

As you can see there are multiple filters and basis like PMTRX , CMTRX , AT . How do we dynamically manage that using regex ? Thanks.

@AhmedKutraphali - Could you please try like this…You can use regex groups to extract the string you want.

@AhmedKutraphali
As an alternate a pattern defining some more restrictions on digit, letter, -

2 Likes

What if I only wanted to get strings that begin with the ff. if and get the value like CMTRX00015591 , PMPay00012345 and so on. If the string does not begin with the example below the regex should ignore it. @prasath17 @ppr .

a. CMTRX
b. PMTRX
c. BT
d. LT
e. PMPay
f. CONCUR-AP-###
G. AT

@AhmedKutraphali …sorry I couldn’t get you…which one you want to omit and which ones you want to keep?

1 Like

I want to keep all data that starts with but only up to the last number it should not include text like General or anything for example CMTRX00015591 ! General . The output should be CMTRX00015591. @prasath17

keep data that start with the following below.

  1. CMTRX
  2. PMTRX
  3. BT
  4. LT
  5. PMPay
  6. CONCUR-AP-###
  7. AT

Another set of data example

El BT-210209-141 !General
o BT-210209-421 General 
El BT-210209-421 General 
o BT-210209-423 General 
El BT-210209-423 General
AL CT-210209-423 General
El CMTRX0012323 General 
o CMTRX00053233 General 
El CMTRX00015591 General 
El CMTRX00015591 General 
El PMTRX0001223 General 
El PMTRX0003232 General 
El CONCUR-AP-34334 General 
El CONCUR-AP-4343 General 
El CONCUR-AP-23342 General 
El PMPay00012345 General 
AL L4-210209-423 General
AL TR-210209-423 General

How would you Like to handle the Case of L4?
L4-210209-423

1 Like

@AhmedKutraphali …we have already provided the regex …please check my screenshot above …your text is under $1 column

1 Like

L4 should not be included since it is not on the list of string that begins with

  1. CMTRX
  2. PMTRX
  3. BT
  4. LT
  5. PMPay
  6. CONCUR-AP-###
  7. AT

@AhmedKutraphali - What about the CT?

1 Like

CT also not included it should only get text that begins with the following

  1. CMTRX
  2. PMTRX
  3. BT
  4. LT
  5. PMPay
  6. CONCUR-AP-###
  7. AT

@AhmedKutraphali - please check below under $1 column

Please find the starter help here: Regex_Ahmed.zip (35.4 KB)

1 Like

@prasath17 One last question sir how do we add a filter or checking that will determine if its a previous date ? in this format YYMMDD

for example if item equal toBT-210210-141 , it should check the date after BT which is 210210(YYMMDD) then the bot will log a message that it is a previous day based on our current date today . Today is 11 and last day is 10 which is 210210 in YYMMDD format. Thanks

@AhmedKutraphali - Please check this…Regex_Ahmed.zip (35.9 KB)

1 Like

Thank you so much @prasath17 . May God bless you.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.