我正在调用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_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\">
我尝试使用Regex摆脱这些方括号[
]
之间的任何内容
这就是我写的:/\[[^]]*\]/g
。
当我在regex website上运行时,此模式匹配,但是当我这样做时:
var exp = /\[[^]]*\]/g;
console.info('WP resp',latestReleaseNotes.content.rendered.search(exp));
它安慰了-1并且不匹配:
WP resp -1
我做错了什么?