Get a number from a string - after a certain word

Hello team ,

I have below examples of string :

  1. PO Box : **32322 EG LM01
  2. po BoX : 34243 ffafa
  3. POBox 32323 sdfodah dada
  4. DAJD Po box : 33122 sdfa
  5. SAJDAH pO boX 424234 DSFS

I want to extract the ‘digits’ after ‘X’ where ‘x’ is the last letter of the word ‘box’
and x can be small or in caps.

so in the above cases i want to get 32322 , 34243 ,32323, 33122 , 424324

→ these digits or the number comes always after ‘x’ or ‘X’
→ i want to get the number till the " " (space) arrives - the number can be of any length . I want to extract the number.

Can you please help me in this string manipulation query?


@gokul1904 ,

Try with this regex \b\d{5,6}\b

@gokul1904 ,

If you need to do it without regex then you can do it with the below piece of code using Assign activity

1 Like

Hi @gokul1904 ,

You can Check with the Below Regex :


We would require to take the Group 1 from the Matched Output.

Expression to be used will be like below :

1 Like

If you only want the number:


Use it with the Assign activity:

number = System.Text.RegularExpressions.Regex.Match(inputText, "(?i)(?<=x\D+)\d+").ToString
1 Like

thanks a lot ! - can you give me the portal link you used for regex validation?


@gokul1904 ,

Sure, Check the Below Link :

1 Like

thanks a lot ! this also works!

1 Like

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