Regular expression for a string that is not the prefix of some other particular string
What is the regular expression that woul开发者_运维知识库d find all instances of the string "&", but not if the instance is the prefix of the string " ".
For example, it would match the "&" in "John & Paul", but not the "&" in "John Paul".
What you're looking for is a negative lookahead (see this answer as well). The syntax would generally be something like:
&(?!nbsp;)
Which matches any ampersand not followed by nbsp;
Something like this may be :
\s&\s
You can try your regex on this website
精彩评论