The regex will look like:
\d+(?:[.,]\d+)?€/g
In Javascript, as a regex object (note that the forward slash needs to be escaped):
/\d+(?:[.,]\d+)?€\/g/
Here's a breakdown of what each part does:
\d+ # one or more digits
(?: # ... don't capture this group separately
[.,] # decimal point
\d+ # one or more digits
)? # make the group optional
€/g # fixed string to match
If you want to allow something like .123€/g to be valid as well, you can use:
(?=[.,]|\d)(?:\d+)?(?:[.,]\d+)?€/g
That is, both the groups of digits are optional, but at least one must be present (this uses lookahead, which is a bit more tricky).
Note that this will also match constructions like 'word2€/g'. If you want to prevent this, start the regex with (?<=^|\s) (matches if preceded by a space or the start of the string) and end it with (?=$|\s) (matches if followed by a space or the end of the string).
Full-blown version:
(?<=^|\s)(?=[.,]|\d)(?:\d+)?(?:[.,]\d+)?€/g(?=$|\s)
.or,as decimal point, so I think not :)parseFloat:parseFloat("40€") == 40.0