I need to extract a set of characters in of a string. I plan on usn开发者_StackOverflow社区g the RegEx.Match method (c#) but I am unclear about the RegEx pattern to use. I want to extract a pattern where it starts with // and ends with ...
Then length needs to be variable inside the matched string but the start and end characters will always be the same. In DOS, I would have done something like the following:
//*...
but I know this is not the correct syntax for RegEx.
Try with pattern
"//.*?\.\.\."
or
"//.*?\.{3}"
Some codes
string data = @"some codes //to double check...
another codes //done...
//to do...";
MatchCollection matches = Regex.Matches(data, @"//(.*?)\.\.\.");
foreach (Match m in matches) {
print(m.Groups[1].Value);
}
results
to double check
done
to do
精彩评论