0
我有文本文件簡單的regex需要
01:02:39.952 MC:My text with several lines
01:02:39.952
我如何能趕上01:02:39.952 MC:
和01:02:39.952
我在這個模式我的文本文件有很多像這樣的行之間的所有文字,我想抓住他們所有人。
我有文本文件簡單的regex需要
01:02:39.952 MC:My text with several lines
01:02:39.952
我如何能趕上01:02:39.952 MC:
和01:02:39.952
我在這個模式我的文本文件有很多像這樣的行之間的所有文字,我想抓住他們所有人。
假設你的模式是不是正是這些數字比較一般:
Regex regexObj = new Regex(
@"
(?<= # Assert that the following can be matched before the current position:
\b # start of ""word""
\d{2}:\d{2}:\d{2}\.\d{3} # nn:nn:nn.nnn
\sMC: # <space>MC:
) # End of lookbehind assertion
.*? # Match any number of characters (as few as possible)...
(?= # ...until the following can be matched after the current position:
\b # start of word
\d{2}:\d{2}:\d{2}\.\d{3} # nn:nn:nn.nnn
\b # end of word
) # End of lookahead assertion",
RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
Match matchResult = regexObj.Match(subjectString);
while (matchResult.Success) {
resultList.Add(matchResult.Value);
matchResult = matchResult.NextMatch();
}
感謝進一步解釋正則表達式。我今天學到了東西。 – h0b0