【发布时间】:2010-07-23 18:57:59
【问题描述】:
我在这里需要正则表达式方面的帮助。
我希望 PHP 能够将字符串拆分为多个数组部分,这样由 包围的子字符串将位于其自己的插槽中。
例如,
Hi there how are <%me date(); %> => {"Hi there how are ", "<%me date(); %>}
Hi there how are you<%me date(); %> => {"Hi there how are you", "<%me date(); %>}
Hi there how are you<%me date(); %>goood => {"Hi there how are you", "<%me date(); %>, "good"
Hi there how are you<%me date(); %> good => {"Hi there how are you", "<%me date(); %>}, " good"}
请注意,空格不会阻止标签被解析。
【问题讨论】:
-
你的例子没有意义。
;来自哪里?"<%me date(); %>},是什么意思?缺少一些双引号!缺少一些结束卷曲!请为所有相关人员的利益进行修复。 -
标签部分也可以包含
%吗? -
很好 preg_split 应该将字符串术语到给定正则表达式模式的数组中。所以我需要将字符串转换为它右侧的数组的正则表达式。抱歉,这是我的错误,但每个 date() 末尾应该有分号。
标签: php regex preg-split