Get digits after digits Regex

Hello all,

I am facing an issue related to capture digits with Regex.

I need to get “5555946”, but I am not able to find the correct code to get “5555946”. Do you know how could I solve this issue?

CALLE
820384318 05555946 268 859

Many thanks in advance! :slight_smile:

Angel

Hi @Angel_Llull you need to fetch “5555946” from 820384318 05555946 268 859 without 0 at the beginning of 05555946 ?

If it is possible from “5555946” but sometimes there are letters. So, it can be from “0” and then I would use substring method :slight_smile:

Hi @Angel_Llull can you please provide some sample inputs, showcasing all the possibilities?

820384318 05555946 268 859

820384456 0PM45276 268 859

820384755 KPM53246 268 859

@Angel_Llull

Why don’t u, use an array to get the second value, seperating with space? Or regex, only if the first value change it length, as that the regex get the value that come after that one with that specific length.

mz3bel

1 Like

Maybe something like this would do:

(?<=^\d+ +\w*)\d{3,}

Note that the multiline option should be on.

2 Likes

Hi @Angel_Llull ,
I would like to know whether the output be like this:

i/p
820384318 05555946 268 859 →
o/p
5555946

i/p
820384456 0PM45276 268 859 →
o/p
PM45276 or
45276

i/p
820384755 KPM53246 268 859 →
o/p
KPM53246 or
53246

Hi,

The outputs should be: 5555946
PM45276
PM53246

Thanks! :slight_smile:

Angel

@Angel_Llull

Hi, something like this ?

IP = 820384318 05555946 268 859
OP = 05555946

IP = 820384456 0PM45276 268 859
OP = 0PM45276

IP = 820384755 KPM53246 268 859
OP = KPM53246

Mohssine

2 Likes

Hi @Angel_Llull ,

(?<=^\d+\s[\w])\w+
I hope this RegEx will help to extract exactly the piece of information you required.

Thank you