mz3bel
(Mohssine HILAL)
May 23, 2019, 3:05pm
1
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
mz3bel
(Mohssine HILAL)
May 23, 2019, 3:12pm
3
@rachrahul2 this aint helping, but thanks!
mz3bel:
[^»]*[\d{1,}]$
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
1 Like
mz3bel
(Mohssine HILAL)
May 23, 2019, 3:19pm
5
1 Like
Did that work buddy @mz3bel
mz3bel
(Mohssine HILAL)
May 23, 2019, 3:23pm
7
@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
mz3bel
(Mohssine HILAL)
May 23, 2019, 3:33pm
9
@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]$
without - symbol
it worked buddy
Cheers @mz3bel
did that work buddy @mz3bel
mz3bel
(Mohssine HILAL)
May 24, 2019, 7:39am
12
@Palaniyappan
Sorry for late response! No i doesn’t work on my side…
mz3bel
(Mohssine HILAL)
May 24, 2019, 1:22pm
13
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
system
(system)
Closed
May 27, 2019, 2:26pm
15
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.