An input string:
string datar = "aag, afg, agg, arg";
I am trying to get matches: “aag” and “arg”, but following won’t work:
string regr = "a[a-z&&[^fg]]g";
string regr = "a[a-z[^fg]]g";
What is the correct way of ignoring regex matches in C#?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The obvious way is to use
a[a-eh-z]g, but you could also try with a negative lookbehind like this :Explanation :
aMatch the character “a”[a-z]Match a single character in the range between “a” and “z”(?<!XXX)Assert that it is impossible to match the regex below with the match ending at this position (negative lookbehind)f|gMatch the character “f” or match the character “g”gMatch the character “g”