字符串操作 [英] String manipulation operation
本文介绍了字符串操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想过滤这样的字符串,它可能包含字符符号等
金额10.05 $
并且我需要一个包含浮点值的输出(在消除了字符串和符号(."除外)之后).
10.05
我尝试了以下代码,但它也消除了小数部分
I want to filter a string like this it may contain characters symbols etc
Amount 10.05 $
and i need an output like this contains a float value ( after eliminating the string and symbols except "." )
10.05
i tried the below code but it eliminate the decimal part also
<pre lang="c#">
key="!$%^ amount 10.05$";
Regex.Replace(key, @"\D", "");
但返回10055
but it returns 10055
推荐答案
并且我需要一个包含浮点值的输出(在消除了字符串和符号(."除外)之后).
10.05
我尝试了以下代码,但它也消除了小数部分
and i need an output like this contains a float value ( after eliminating the string and symbols except "." )
10.05
i tried the below code but it eliminate the decimal part also
<pre lang="c#">
key="!
%^ amount 10.05
%^ amount 10.05
"; Regex.Replace(key, @"\D", "");
"; Regex.Replace(key, @"\D", "");
但返回10055
but it returns 10055
这篇关于字符串操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文