vansanblch vansanblch - 1 year ago 99
PHP Question

Finding all PHP short tags

I need to find all short PHP tags.

The regex for it

but I can not use it in vim.

How to "convert" it to vim?

Answer Source

The best way to find short-tags in vim is to find all occurrences of <? not followed by a p:


The reason your regex is failing in vim is because /? finds literal question marks, while \? is a quantifier; /<\? in vim will attempt to find 0 or 1 less-than signs. This is backwards from what you might expect in most regular expression engines.

If you want to match short tags that are immediately followed by a new line, you cannot use [^p], which requires there to be something there to match which isn't a p. In this case, you can match "not p or end-of-line" with

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download