RegEx specific digit after string

Hi I need your help in to extract the expression from the following text.
I only want the number at the end

The string as is (including lines)

“B/N for company
Company name
Company address
Company city



B/N is the key word that found in each search content



Use this regex for number



Hey @BHA

Thank you for the sample and expected output. Can you tell us more about the pattern, will it always be that many numbers etc or minimum length will always be…

You can use the Matches activity or use an assign activity like this.

Preview the result here

Assign Left:
Assign Right: System.Text.RegularExpressions.Regex.Matches(INSERTxINPUTxSTRINGxVARIABLE,“^\d{5,}”)(0).ToString

This will grab the digits but must be 5 or more long and only at the start of a new string. So it shouldn’t catch any numbers in the address etc your but if it is, increase the “5”.

If you want to learn Regex - check out my Regex MegaPost for new users :blush:



Thanks for your reply

The thing is
That string is only partial from a very long string (pdf scraping)
How do you advice using regex


Okay, so either post a full sample (remove customer data etc) or tell us more about the pattern of text. You may need to go away and find out more. For Regex, we need to know what is consistent so we can make a robust pattern. Like will there always be a dash below the numbers?


There will be always-

And the most reliable identifier is the
I basically want to say
I want the first number occurs after the word B/N for company
However that number might be located after one to three lines depending on the company information


Do you have any information on how long the Digits will be?

I might have a solution for you below its based up the line which “B/N” in it.

Preview it here (1, 2 or 3 lines in the sample text).

Assign Left:
Assign Right: System.Text.RegularExpressions.Regex.Matches(INSERTxINPUTxSTRINGxVARIABLE,“(?<=B/N.+[\n\r]+.+[\n\r]+.[\n\r]+.[\n\r]+)^\d+”)(0).ToString

You could also use the dash solution. It is simple but may not meet your needs.



This is brilliant

You are RegEx master

Thanks a lot

1 Like

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