Regex -忽略内部word + html

Regex - ignore inside word + html

本文关键字:word html 内部 Regex      更新时间:2023-09-26

尝试用我有限的正则表达式知识从下面选择单词"content"(使用javascript):

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

(['S]*)content(['S]*)
这让我得到了没有空格的"内容",但也带回了P标签和"peoplecontent"——我只希望它不是另一个词的一部分。我需要把一些not串在一起,对吧?

使用'b,即字边界元字符

/'bcontent'b/g