开发者

Check if two parts of a string are the same with regex (PHP)?

using a regular expression in PHP with preg_replace_callback how can I check if two parts of the pattern are the same?

preg_replace_callback('/Blah: (.*?), BLah Blah (.+?), (**Strin开发者_Go百科g Here Must Be Same as First Match**)/s', create_function(), $subject);

Thanks, Matt


You can use a backreference:

/Blah: (.*?), BLah Blah (.+?), \1/s

\1 here denotes the first matched group.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜