Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
この質問の Joey に感謝します。私は、Regex.Replaceこのように見えます
Regex.Replace
Regex.Replace(Txt, "[^-?\d+\.]|(?<=\.[^.]*)\.", "");
しかし、今はコンマ ( ) を 1 つだけ許可したいので,、ユーザーはコンマまたはドットのいずれかを使用できますが、両方を使用することはできません。
,
どうすればそれを実装できますか?
したがって、法的な数字は
2.324324 0.34345325 2,5454 0,453453
これを試して:
string result = Regex.Replace(Txt, @"[^\d.,]|(?<=[.,][^.,]*)[.,]", "");