Created
June 27, 2018 07:36
-
-
Save polarstars/741e3fdf8aef9272c07632d7c540b8e2 to your computer and use it in GitHub Desktop.
提取字符串中的浮点数 #C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static double ExtractDouble(this string str) | |
{ | |
Regex Reg = new Regex(@"[-+]?[0-9]*\.?[0-9]+"); | |
Match m = Reg.Match(str); | |
if (m.Success) | |
return Convert.ToDouble(m.Value); | |
else | |
return 0.0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment