単語を区切るために使用される少なくとも3つのハッシュを含む文字列に一致する正規表現は何ですか?
一致:
the-rain-in-spain
the-rain-in-spain-is-falling-on-the-plain
一致していません:
the-rain-in
the---in
私はphpについて知りませんが、これは私のために働いています
//string strtmp = "the-rain-in";
//string strtmp = "the-rain-in-spain";
string strtmp = "the-rain-in-spain-is-falling-on-the-plain";
//string strtmp = "the---in";
Match matchdec = Regex.Match(strtmp, @"\w+(-\w+){3,}", RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase);
if (matchdec.Success)
{
//your code
}
お役に立てれば
この正規表現を使用できます
\w+(-\w+){3,}
\w
と類似しています[a-zA-Z0-9_]
\w+
1 対多の文字に一致
{3,}
前のグループ 3 に何回も一致する量指定子です