環境:Visual Studio 2008 SP1正規表現を使用して文字列から整数を取得する
この場合、かっこと100の間の整数を取得する正規表現は何ですか?
string input = "bunch of text(100): more text here ignore the 1 or 2 ints here";
環境:Visual Studio 2008 SP1正規表現を使用して文字列から整数を取得する
この場合、かっこと100の間の整数を取得する正規表現は何ですか?
string input = "bunch of text(100): more text here ignore the 1 or 2 ints here";
をされること:
\d+
C#コード(もちろん、using System.Text.RegularExpressions
が必要です):
Regex re = new Regex(@"\d+");
string input = "bunch of text(100): more text here";
Match m = re.Match(input);
if(m.Success) {
// Your number is in m.Value
} else {
// No number in the string
}
[0-9] +(?:\。[0-9] *)?
次回、このウェブサイトを参照してください:http://gskinner.com/RegExr/
素敵なリソースを更新してくれてありがとうございます。 – Rod
本当に正規表現に新しいと苦労答えを得るために少し。 – Rod
申し訳ありませんが、OP – Rod