Regex匹配特定的标记和介于两者之间的任何字符



我正在尝试使用regex来匹配特定标签以及特定标签之间的任何字符/内容。请注意,标签之间的内容是动态的,因此可以更改。

我想匹配[vc_row el_class="英雄cta[/vc_row]之间的所有内容

我用下面的regex尝试了这一点,但问题是它匹配所有[vc_row]标签,因为我希望只能匹配[vc_row el_class="hero-cta标签、内部内容和结束[/vc_row][/strong>标签

我尝试的正则表达式(不正确,因为它匹配所有[vc_row]标记(

[vc_row el_class=[^]].*"]([sS]*)[/vc_row]

如何调整此正则表达式?

内容

<!--match-->
[vc_row el_class="hero-cta image_flush_bottom" css=".vc_custom_1382221210419{background-color: #511068c !important;}"][vc_column][vc_row_inner el_class="container-row-margin-btm-override"][vc_column_inner width="2/3"][vc_column_text]
<h2><em><strong>Download Guide</strong></em></h2>
[/vc_column_text][/vc_column_inner][vc_column_inner width="1/3"][vc_single_image image="12346" img_size="full" alignment="center" onclick="custom_link" link="https://www.website.com/test-page"] 
[/vc_column_inner][/vc_row_inner][/vc_column][/vc_row]
<!--//match-->
<!--ignore-->
[vc_row][vc_column][breadcrumb][/vc_column][/vc_row]
<!--//ignore-->

在WordPress中有函数get_shortcode_regex用于查找所有短代码。

echo get_shortcode_regex( [ 'vc_row' ] );

此常规程序可以帮助您查找所有vc_row短代码。您可以根据自己的目的重新格式化此正则表达式。

相关内容