0

単語を区切るために使用される少なくとも3つのハッシュを含む文字列に一致する正規表現は何ですか?

一致:

the-rain-in-spain
the-rain-in-spain-is-falling-on-the-plain

一致していません:

the-rain-in
the---in
4

2 に答える 2

0

私は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
       }

お役に立てれば

于 2013-02-19T05:54:07.873 に答える
0

この正規表現を使用できます

\w+(-\w+){3,}

\wと類似しています[a-zA-Z0-9_]

\w+1 対多の文字に一致

{3,}前のグループ 3 に何回も一致する量指定子です

于 2013-02-19T05:20:30.303 に答える