Regular Expression all characters except last one

后端 未结 2 577
无人共我
无人共我 2020-12-14 21:20

This is my string: 50.00.00..00.00

I want to match all . except the last one, so after a replace I end up with 50000000.00

2条回答
  •  自闭症患者
    2020-12-14 21:36

    \.(?=.*\.)
    

    Matches a dot (\.), which there must be another dot following it ((?=.*\.)).

    (This assumes the regex engine supports lookahead, e.g. PCRE, Python, etc.)

提交回复
热议问题