dropping characters from regular expression groups
Posted
by
tcurdt
on Stack Overflow
See other posts from Stack Overflow
or by tcurdt
Published on 2010-12-24T23:29:33Z
Indexed on
2010/12/24
23:54 UTC
Read the original article
Hit count: 152
regex
The goal: I want to convert a number from the format "10.234,56" to "10234.56"
Using this simple approach almost gets us there
/([\d\.]+),(\d\d)/ => '\1.\2'
The problem is that the first group of the match (of course) still contains the '.' character.
So questions are:
- Is it possible to exclude a character from the group somehow?
- How would you solve this with a single regexp
(I know this is a trivial problem when not using a single regexp)
© Stack Overflow or respective owner