Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这是我的代码:
<html> titi <? print "toto"+"<br>" ?> <html>
我只想要<? and ?>我发现的唯一正则表达式之间的行:
<? and ?>
<?.*\n*?\?>
但它缺少第一个<?
<?
所以如果有人有任何想法,它会让我发疯......向所有人致以问候和感谢。比西埃
你应该逃避第一个?:
?
<\?.*\n*?\?>
我认为这个正则表达式会更健壮:
<\?.*?\?>
(指定多行选项,因此.也将匹配换行符)
.
您需要在第一个问号之前添加一个反斜杠(您也应该使用正则表达式的多行模式):
逃脱第一?