How to remove dollar format with regex

前端 未结 8 1921
北荒
北荒 2021-01-21 02:42

I am trying to remove the dollar format from the string \'$1,109,889.23\'. I tried using a regular expression with:

\"[^\\\\d]\" 

but then I ge

8条回答
  •  无人及你
    2021-01-21 03:17

    You don't need a regex for this.

    Just use lsParseCurrency:

    numericValue = lsParseCurrency('$1,109,889.23'); writeOutput(numericValue);

    Example on trycf.com yields:

    1109889.23

    As per Leigh's commment below... if yer locale is something that doesn't use , and . for the thousands and decimal separators (respectively)... make sure to specify the locale too, eg:

    numericValue = lsParseCurrency('$1,109,889.23', 'en_us');

提交回复
热议问题