在vb.net中使用RegEx从string获取值的double值 [英] Get value double value from string using RegEx in vb.net
本文介绍了在vb.net中使用RegEx从string获取值的double值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下字符串值来自数据库。
I have following string value which is coming from database.
str= ">= 5.0 years"
现在从这个字符串我想要double数字(5.0)的值。我可以从这个字符串中获得这个值吗?
Now from this string i want the value of double number (5.0). How can i get this value from this string?
任何人都可以告诉我如何从上面的字符串中获取5.0的价值?
Can any one tell me how to get the value like 5.0 from above string?
提前感谢
推荐答案
尝试使用此模式:
PATTERN
\d+?.\d+
我不知道如何在Visual Basic中使用正则表达式,但是这个C#代码应该可以帮助你:
I'm not sure how to use regex in Visual Basic, however this C# code should help you:
C#代码
string regex = @"\d+?.\d+";
string myString = ">= 5.0 years";
MatchCollection matches = Regex.Matches(myString, regex);
foreach(Match m in matches)
{
Console.WriteLine(m);
}
Console.ReadLine();
这篇关于在vb.net中使用RegEx从string获取值的double值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文