RegEx for capturing digits in a string

I’m looking to extract only the numbers after this “=»”, but i keep having some other text too:

Regex code:

[^»]*[\d{1,}]$

Input

login as: LOGIN SERVER@00.00.00.000’s password: Last login: Thu May 23
15:51:49 2019 from 00.00.00.000 CREER AUTANT DE REPERTOIRES SOUS
/NAME/NAME/NAME QU’IL Y A DE COMMERCANTS GERES. LE NOM DOIT ETRE LE NO
DE COMMERCANT. CREER ENSUITE SOUS CHACUN D’EUX UN REPERTOIRE NAME/
ps -fu NAME | grep exe | echo «resultat=»wc -l «resultat=»14

How do I solve this problem?

2 Likes

@rachrahul2 this aint helping, but thanks!

Buddy @mz3bel

use this expression buddy (remove the *)
[^»][\d{1,}]$

and you will get the value of 14 next to =>> as a second match
Cheers @mz3bel

@Palaniyappan i get this https://regex101.com/r/NJrRNJ/7

1 Like

Did that work buddy @mz3bel

@Palaniyappan, ok i see what you mean. There’s only a small problem, number 14 should change, so it’s like i need only the numbers after “=»”

Mean,…i didn’t get you buddy @mz3bel

@Palaniyappan number 14, can change from -1 to 15000. so i need the regex code to take all numbers after this “=»”

1 Like

use this expression buddy @mz3bel
[^=»]*[0-9]$
image
image

without - symbol
image

it worked buddy
Cheers @mz3bel

did that work buddy @mz3bel

@Palaniyappan

Sorry for late response! No i doesn’t work on my side…

Characters in square brackets mean “one of these characters”, so it’s ? or » followed by a digit or { , 1 , , or } .

Positive lookbehind is the most useful here (match something that comes after X .)

(?<=something)thingIWantToMatch

So:

(?<=»)\d+

One or more digits preceded by a » , but don’t capture the »

1 Like

Good to know that you managed to solve it :slight_smile:

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