开发者

Visual Studio 2010 Find and Replace Regular Expression Help (for php short tags)

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: \<\?=\({(.#)}\)\?\>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜