短代码插件无法识别正则表达式中的换行符

时间:2021-05-02 12:13:28

I am using a Joomla shortcode plugin which hunts out shortcode codes and replaces them with html content. It works well, that is, until the user inserts a linebreak at which point it fails. I believe it is something to do with the regex but knowing almost nothing about regex I cant see what. Here is the regex that finds my shortcode...

我正在使用Joomla短代码插件来搜索短代码并用html内容替换它们。它运行良好,也就是说,直到用户插入换行符,此时它才会失败。我相信它与正则表达式有关,但对正则表达式几乎一无所知我无法看到什么。这是找到我的短代码的正则表达式...

"tab"=>array("codeHolder"=>"[LOFG-TAB-HOLDER-%d]",
"codeCheck"=>"[BStabs",
"codeModifier"=>"#\[BStabs(.*?)\](.*?)\[/BStabs\]#e",
"codeMakeHolder"=>"'[LOFG-TAB-HOLDER-' . PlgSystemIceShortCodes::getCount('tab') . ']'",
"regex"=>'/\[BStabs(.*?)\](.*?)\[\/BStabs\]/im')

I need the regex to recognize/ignore line breaks in the inputted shortcode - how is this done?

我需要正则表达式来识别/忽略输入的短代码中的换行符 - 这是怎么做到的?

1 个解决方案

#1


0  

It looks like the regex patterns allow you to post the full regex including modifiers

看起来正则表达式模式允许您发布包含修饰符的完整正则表达式

To make the dot (.) character match newlines, you simply need to add the s flag, eg

要使点(。)字符与换行符匹配,您只需添加s标志,例如

"regex"=>'/\[BStabs(.*?)\](.*?)\[\/BStabs\]/sim'

#1


0  

It looks like the regex patterns allow you to post the full regex including modifiers

看起来正则表达式模式允许您发布包含修饰符的完整正则表达式

To make the dot (.) character match newlines, you simply need to add the s flag, eg

要使点(。)字符与换行符匹配,您只需添加s标志,例如

"regex"=>'/\[BStabs(.*?)\](.*?)\[\/BStabs\]/sim'