11

Context:

Handeling PHP 2-3 codes I have to replace short tag "<?" by "<?php".
In order to find them I wanted to use the VS code find in folder feature to find all occurrence of it.

Question:

What is the correct syntax for contains <? not followed by php?

I've read the visual studio documentation here and tried in regex101. It seems to be valid in PCRE and ECMA. I must be missing something, because in Visual Studio Code it doesn't work.

"Regex parse error".

enter image description here

Regex:

<\?(?!php)

Input:

<?php
<?
<?PHP

Output:

<?
Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
xdtTransform
  • 1,986
  • 14
  • 34
  • 4
    Check *User Settings* -> *Features* -> *Search* settings for the `Use PCRE2` option. It must be checked for lookaheads to work. – Wiktor Stribiżew Apr 28 '19 at 10:37
  • @WiktorStribiżew, Hoo, great! May you make an answer when you have time. I feel like if it's not a dupe, it will be usefull to others. – xdtTransform Apr 28 '19 at 10:40
  • Also that doc you referred to is for Visual Studio, not Visual Studio Code. – revo Apr 28 '19 at 10:40
  • @revo, I hit google with `"Visual Studio Code"` but he still ignored it. I guess the word "code" is really common on those page. – xdtTransform Apr 28 '19 at 10:42
  • 2
    And https://stackoverflow.com/questions/52149634 , damnezd dupe is easy once you know the name of the feature. – xdtTransform Apr 28 '19 at 10:47

0 Answers0