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!
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
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
mz3bel
(Mohssine HILAL)
November 30, 2020, 10:43am
6
@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
ptrobot
November 30, 2020, 10:51am
7
Maybe something like this would do:
(?<=^\d+ +\w*)\d{3,}
Note that the multiline option should be on.
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
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!
Angel
mz3bel
(Mohssine HILAL)
November 30, 2020, 12:17pm
10
@Angel_Llull
Hi, something like this ?
Regular expression tester with syntax highlighting, explanation, cheat sheet for PHP/PCRE, Python, GO, JavaScript, Java, C#/.NET.
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