Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
ここで何が欠けていますか?
Regex _validityRegEx = new Regex(@"^(<minStay>.{2})\/(<maxStay>.{2})$"); Match validityMatch = _validityRegEx.Match("--/3M);
2 つのグループが必要です。1 つは最初の 2 文字を含み、もう 1 つは次の 2 文字を含みます。/
/
次のパターンを使用してください ( を見逃しています?):
?
@"^(?<minStay>.{2})/(?<maxStay>.{2})$"
次のようなグループにアクセスできます。
var minStay = validityMatch.Groups["minStay"].Value var maxStay = validityMatch.Groups["maxStay"].Value