正则表达式 - 忽略单词+ html

时间:2015-07-21 14:10:47

标签: javascript html regex

尝试选择"内容" (使用javascript)我从以下有限的正则表达式知识:



Here is content <p>content</p> content. Content contentpeople peoplecontent peoplecontentpeople
&#13;
&#13;
&#13; 使用正则表达式:

&#13;
&#13;
([\S]*)content([\S]*)
&#13;
&#13;
&#13; 这让我得到了内容&#34;没有空格,但也带回了P标签和#34; peoplecontent&#34; - 我只想要它不是另一个词的一部分。我需要将一些NOT链接在一起吗?

1 个答案:

答案 0 :(得分:3)

使用\bword boundary metacharacter

/\bcontent\b/g