Extract 10 digit number from string

Hi all,

I have a string for example:

String1: /TYPE/000/R SEPA TR//XXXX/XX//XXXX/2000000000//XXXX/NOTPROVIDED//XXXX/NAME/XXXXXXX XXXX//INFO/XXXXXXXX//XXX/XXXXXXXX/

String 2: /TYPE/000/X XXXX XX//CODE/XX//BORI/Dossiernummer: 2111111111 Invoice: 2233333333 (betaling week 00)//XXXX/XXXXXXXXXX//XXXX/NAME/XXXXXXX//INFO/XX00XXXX0000000000//ABC/XXXXXX0XXXX/

String 3: /TYPE/000/R SEPA TR//XXXX/XX//XXXX/Dossiernummer 1700000000//EREF/NOTPROVIDED//XXXX/NAME/XX XXXXX XX XXX//INFO/XX000000X0000//XXX/XXXXXXXXXX/

I want to extract the following strings: 2000000000, 2111111111, 1700000000.

These are Reference numbers that i need to extract based on the following filters:

  • must start with 17,18,19,20,21
  • the lenght of the reference nr is 10
  • The reference nr contains only numbers from 0 to 9 (no letters or symbols)

Can you help me out with this?
Much appreciated!!!

@RaduNRV - Here you go…

https://regex101.com/r/bPSzdK/1/

\b(17|18|19|20|21)\d{8}\b

you can see String4 in the text is not selected in the link because it is 11 characters even though it is starting with 17

String 5 has letters and starts with 18 length is 10 , not selected

1 Like

Hi,

Can you try the following expression?

System.Text.RegularExpressions.Regex.Matches(yourString,"(?<=^|\D)(17|18|19|20|21)\d{8}(?=\D|$)")

Sample20210526-3.zip (2.6 KB)

Regards,

1 Like

It works fine but what is the full regex expression to use? I’m reading the CSV file in a read csv activity and how do i save that reference number in a variable ?

@RaduNRV - You can try this way…

Read CSV
Output Datatable activity → this will give you the StringOutput
Then pass the StringOutput to Matches activity
Loop through Regex Output and Store the Variables…

I need to read each row in the datatable and where it matches i need to add it to Orchestrator queue. Any other idea ?