How can I write a c# regular expression to use for replacing an ampersand (&) with consideration that the ampersand occurrence could be in & > © or AT&T
For example… Regex.Replace(“(\S)&(\S![^;])”, “$1&$2”);
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.
To directly replace
"&"with"&you don’t need a regex, just useString.Replace(orStringBuilder.Replace).However to replace
"&"where it isn’t followed by a"amp;"does need a regex, and a “Zero-width negative lookahead assertion“:11 The reason to use a zero-width assertion is to handle
"&"at the end of the string.