Given the string:
/home "1020....2010" main
I would like home, 1020 and 2010 using regex, but keep having problems with the quote. Can anyone help me out?
Thank you guys for your post. I realize that my code might have some problem. Here it is
string pattern[1] = @”blablabla”;
string pattern[2] = @”blablabla”;
……
foreach (string s in pattern) {
if (regex.match(line, s).success) {
……
}
}
Then there is error saying unexpected character “\”
Use the pattern:
And
home(or any other name after the/) will be in$1, the first number in$2and the last number in$3.EDIT 1
I thought the
@should work, but couldn’t get it to compile in ideone.com. This does work however:produces:
Test rig: http://ideone.com/TpQwf
EDIT 2
As @Seattle mentioned in the comments, when using the convenient
@before a regex-string, the double quotes needs to be escaped by placing a double quote in front of it (not a backslash!):