[英]Regex Match multiple occurences with numbers in string C#
我一直在尋找我的問題答案,但找不到,所以我在這里寫。
我想以字符串為例:=“37513220102304920105590”
並找到長度為11且從3或4開始的所有匹配項。
我一直試圖這樣做:
string input = "37513220102304920105590"
var regex = new Regex("^[3-4][0-9]{10}$");
var matches = regex.Matches(trxPurpose);
// I expect it to have 3 occurances "37513220102", "32201023049" and "30492010559"
// But my matches are empty.
foreach (Match match in matches)
{
var number = match.Value;
// do stuff
}
我的問題是:我的正則表達式是壞的還是我做錯了什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.