开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜