Regex to remove all (non numeric OR period)

后端 未结 5 962
陌清茗
陌清茗 2021-02-02 04:46

I need for text like \"joe ($3,004.50)\" to be filtered down to 3004.50 but am terrible at regex and can\'t find a suitable solution. So only numbers and periods should stay -

5条回答
  •  耶瑟儿~
    2021-02-02 05:12

    This should do it:

    string s = "joe ($3,004.50)";
    s = Regex.Replace(s, "[^0-9.]", "");
    

提交回复
热议问题