Last Updated: February 25, 2016
·
1.162K
· rican7

Vim, Regex, and PHP - Search for PHP Namespace

Negative and positive look-behinds are kind of awkward in Vim's flavor of Regex... so I figured I'd publish this regex that took me longer than it should have to figure out:

/\(namespace\s\)\@<=.*\(;\)\@=

Boom. There you go. Now you have the namespace... and ONLY the namespace in your search highlight. This could be used for some result parsing or what have you, instead of just doing a more basic /namespace\s\(.*\);.

Hope this helps someone else!
If not, its at least archived for my own reference. :P