c# - regex split and filter construction -
i need filter input, string inside parenthesis: test1, test2, test3. have try, not working.
string input = "test test test @t(test1) sample text @t(test2) else @t(test3) "; string pattern = @"[@]"; string[] substrings = regex.split(input, pattern);
you can use simple match instead.
(?<=@t\().*?(?=\)) string strregex = @"(?<=@t\().*?(?=\))"; regex myregex = new regex(strregex, regexoptions.none); string strtargetstring = @"test test test @t(test1) sample text @t(test2) else @t(test3) "; foreach (match mymatch in myregex.matches(strtargetstring)) { if (mymatch.success) { // add code here } }
Comments
Post a Comment