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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -