6
With the following expression (,)([0-9]*) manage to catch the ,25 but would like to catch only the 25.
decimal (10,25)
In this case how can I disregard the ,
6
With the following expression (,)([0-9]*) manage to catch the ,25 but would like to catch only the 25.
decimal (10,25)
In this case how can I disregard the ,
8
If what you want is simply to leave only the number in a capture group just take the comma out of the parentheses:
,([0-9]*)
To ensure you have any number you can use the +
instead of *
(can use the \d
instead of [0-9]
if you want):
,(\d+)
friend, thank you so much for the help, of the options I chose yours as the best alternative.
Okay, @Iagoleão! Consider marking the answer as accepted then.
5
Use the following regular expression that will work:
(?<=,)([0-9]+)
This regular expression uses lookbehind
that nothing else is to find the values of the defined group ([0-9]+)
if before he finds the comma (?<=,)
.
A complete explanation about lookahead
and lookbehind
can be found on this website.
Follow a code exeplo with Python:
import re
m = re.search('(?<=,)([0-9]+)', '(0,25)')
print m.group(0) #25
I don’t know what language OP is using, but I would like to warn him that this answer, as far as I know, does not work in Javascript (for example) for lack of lookbehinds support.
-3
Just use (,25)
,takes all occurrences of ,25.
\w,(25*)
to the full number.
Test in Regexr
it wants to return only the numbers after the comma, not the comma and only the number 25
True... I’ll keep the answer so you can see how it’s not done.
Browser other questions tagged regex
You are not signed in. Login or sign up in order to post.
Consider informing the programming language that you are using Iago, as regex implementations may vary between languages.
– gmsantos