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: 119

Filed under:

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:

  1. Is it possible to exclude a character from the group somehow?
  2. 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

Related posts about regex