I have some php scripts that I need to short tags with their full blown alternative, I'm using vs.php for visual studio 2010 and what to do a Find And Replace using regular expressions. so far I have the following:
Fi开发者_运维问答nd RegEx: \<\?=\({(.+)}\)\?\>
Replace RegEx: \<\?php echo \1 \?\>
This works fine if there is only one short tag in a line but if there are two or more then it doesn't work properly, it finds the last instance of ")\?>" and I just want to find the next. eg.
Test: <?=($foo)?>
Result: <?php echo $foo ?>
OK
Test: <?=($foo)?> <?=($bar)?>
Result: <?php echo $foo)?> <?=($bar ?>
Not OK
You want is a minimal match--what most other regex flavors call a non-greedy match. In VS you do that by using @
or #
in place of *
or +
:
Find RegEx: \<\?=\({(.#)}\)\?\>
精彩评论