regex - Regular Expression - Not matching certain characters and position of characters -


solution: solved using regex provided gary_w below , simple powershell command uses discussed replacement function. there no need use built in regex activity in software use. here´s ps: "100,000.00" -replace "([,.]\d{2}$)|[,.]",""

regular expressions freaking me out. cannot used logic. however, think current re problem quite simple 1 bur cannot make work :(

so here´s want achieve: want re match digits before last 2 decimal places. thus, re must ignore "." , "," , last 2 digits.

> examples: > 1.000.000,00 --> 1000000 > 123,456.00 --> 123456 > 100.000,00 --> 100000 > 10.000,00 --> 10000 > 10,000.00 --> 10000 > 1.000,00 --> 1000  > 100,00 --> 100 > 99.88 --> 99  > 99,88 --> 99  > 1,23 --> 1  > ... 

any ideas how working?

here's how in oracle, it's worth. maybe regex used here give idea. read regex "look match of comma or decimal followed 2 digits @ end of line, or comma or decimal , replace nothing. note match optional decimal places @ end needs first in regex, otherwise single characters matched first, making 2 decimal places non-existent , not matched.

sql> tbl(str) (      select '1.000.000,00' dual union      select '123,456.00' dual union      select '100.000,00' dual union      select '10.000,00' dual union      select '10,000.00' dual union      select '1.000,00' dual union      select '100,00' dual union      select '99.88' dual union      select '99,88' dual union      select '1,23' dual union      select '3' dual    )    select str,           regexp_replace(str, '([,.]\d{2}$)|[,.]') fixed    tbl;  str          fixed ------------ ------------ 1.000.000,00 1000000 123,456.00   123456 100.000,00   100000 10.000,00    10000 10,000.00    10000 1.000,00     1000 100,00       100 99.88        99 99,88        99 1,23         1 3            3  11 rows selected.  sql> 

just saw regexr link, plugging in regex looks works global flag. characters wish remove highlighted.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -