为什么这个正则表达式会忽略其余的匹配?

I want to match all occurrences for pony word, except in these situations:

  • [url=pony.com]pony[/url]
  • [url]pony.com[/url]

In synthesis, the matches should be:

pony en pony [url=pony.com]pony[/url], también tengo que pony [url=pony.com]pony[url], y no olvidar a [url]pony.com[/url]

To accomplish the goal, I have created this regex:

(?!\[url[^\]]*?\])(pony)(?![^\[]*?\[\/url\])

However, for some some reason, the matches are the following:

pony en pony [url=pony.com]pony[/url], también tengo que pony [url=pony.com]pony[url], y no olvidar a [url]pony.com[/url]

Why is happening this? My idea at first place it to find the correct occurrences, and then, replace them using php.

It matches the following conditions because you are missing a forward slash.

pony en pony [url=pony.com]pony[/url], también tengo que pony [url=pony.com]pony[url], y no olvidar a [url]pony.com[/url]

                                                                   ^ missing '/'

Add the slash and it works, see live demo