Reputation: 137
i have the text:
<a href="blahblahblah-dynamic" class="blahblahblah-dynamic"
title="blahblahblah-dynamic">2.550,00 €</a>1000 € 900 € 5000 € ......
and the expression:
#(\d+[\.\,]\d*?)\s?[€]#su
that matches:
550,00
example in: regexr
How can I match the whole:
2.550,00
?
p.s I dont want to match the others 1000, 900 and numbers without ,
and/or .
In other words, I want to match d,d or d.d,d
so the question possible duplicate, does not cover my case.
Can someone help me on this?
Upvotes: 1
Views: 60
Reputation: 163437
You might use:
([0-9]{1,3}(?:.[0-9]{3})*\,[0-9]+)\s?€
This will match in a capturing group 1-3 digits. Then repeats in a group a dot and 3 digits and at the end will match a comma followed by one or more digits.
After the capturing group \s?[€]
is matches but is not part of the group.
If you want to match exactly 2 digits after the comma you could update ,[0-9]+
to ,[0-9]{2}
As an alternative you could match your value without a capturing group and use a positive lookahead (?=\s?[€])
to assert that what is on the right side is an optional whitespace character followed by €
[0-9]{1,3}(?:.[0-9]{3})*\,[0-9]+(?=\s?€)
Upvotes: 1
Reputation: 98
i'm guessing you got that value in a variable or something , why not try get it with
$value = substr($dataReceivedFromA, 0, -1); // returns "2.550,00 "
i really think there is no point in using regex here if you only wanna get rid of the sign
Upvotes: 0