Extract a 10 digit numeric from string using regular expressions

  • 19 October 2016
  • 2 replies
  • 4 views

Badge

I need to extract a 10 digit numeric from string using regular expressions.

The 10 digit numeric is prefixed with N  (e.g. N121212127)

This string will be within a longer string e.g. abc xyz N121212127 abc 123

Extract to return 121212127 in this example.

Any assistance would be appreciated 


2 replies

Badge +11

Hi ,

If you still have not found solution then here is (not efficient) way of doing it.

Add Regular expression action in your workflow, use pattern as : N[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]

Use action as extract and save to variable varStr

Use another Regular expression, use pattern: N

Use action as replace. The replacement text will be blank and input text will be varStr. Store the result back to varStr.

e.g. if str is : This is N453432563 times number

output after 2 regular expressions should be 453432563.

Userlevel 5
Badge +14

it's even possible with single regex like

(?!N)d{9}

btw, there is just 9 digits in your example...

Reply