Javascript 运行在wordpress标签上的正则表达式
我正在调用wordpress API并获取一篇文章的内容,但其中有标记,我正在尝试过滤它们以获得实际的HTML,下面是一个示例:Javascript 运行在wordpress标签上的正则表达式,javascript,regex,Javascript,Regex,我正在调用wordpress API并获取一篇文章的内容,但其中有标记,我正在尝试过滤它们以获得实际的HTML,下面是一个示例: <p>[vc_row css=”.vc_custom_1499904320526{margin-top: 0px !important;border-top-width: 0px !important;padding-top: 5px !important;}”][vc_column][vc_c
<p>[vc_row css=”.vc_custom_1499904320526{margin-top: 0px
!important;border-top-width: 0px !important;padding-top: 5px
!important;}”][vc_column][vc_custom_heading
source=”post_title”
font_container=”tag:h2|text_align:center”
use_theme_fonts=”yes”][vc_column_text]<strong>START
HERE</strong></p>\n<p>Release Date:<br />\nVersion:</p>\n<p>I am text
block. Click edit button to change this text. Lorem ipsum dolor sit amet,
consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper
mattis, pulvinar dapibus leo.</p>\n<p>[/vc_column_text][/vc_column]
[/vc_row][vc_row][vc_column width=”1/4″
offset=”vc_hidden-lg vc_hidden-md vc_hidden-sm vc_hidden-xs”]
<style type=\"text/css\" scoped=\"scoped\">
它的结果是a-1,但不匹配:
WP resp-1
我做错了什么?您需要在另一个
[]
中转义]
,因为它会关闭表达式
var exp = /\[[^\]]*\]/g
您确定要使用正则表达式解析html标记吗?@cᴏʟᴅsᴘᴇᴇᴅ 我应该用什么?我的最终目标是不使用wordpress标记的HTML在regex101中使用正确的语言设置。见vs。
var exp = /\[[^\]]*\]/g