Skip to main content

Hi, I need to find and extract numbers from a string of text, numbers and characters (see example below). The conditions needed are that the number string can only be between 8 and 14 digits long.

I'm inexpericed with writing Regex but following some previous guidance from this wonderful FME community I did make a start (see below) however it's not doing exactly what I need it to do.

Initally I thought I had solved this until I realised the data has number strings of between 8 and 14 digits/ I'm using the String Searcher transformer.

My expression seems to be finding strings of 8 (or more) digits but only extracting the first 8 digits. This means that when the number string is greater than 8 it cuts the trailing numbers off (se below).

The data I have been provided with is messy to say the least!

In addition to the above question I'd like to ask if its possible to identify and extract, from results of the above, number strings of 8 digits that start with the digit '23'.

In the example below I'd like the extression to find the entire 11 digit string then find 'within' the string the number '23627372'

 

Any help would be greatly appreciated.

(\d{8,14}) 

will match between 8 and 14 numbers

If you know they are always sandwiched between two underscores, i'd probably add in a lookahead and lookbehind too

(?<=\_)\d{8,14}(?=\_)

Once you've matched your longer number, you could extract the last eight digits into a new attribute if they start with 23

0684Q00000ArLGYQA3.png

Alternatively, if it's always the last 8 digits of a possibly longer number you need, you could just use a single regex statement, which would extract the 8 digits that are followed by an underscore

\d{8}(?=\_)

Reply