简体   繁体   English

正则表达式-忽略Word + HTML内部

[英]Regex - ignore inside word + html

trying to select the word "content" (using javascript) with my limited regex knowledge from the below: 尝试从以下有限的正则表达式知识中选择“内容”一词(使用javascript):

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

 ([\\S]*)content([\\S]*) 
This gets me "content" without the spaces but is also bringing back the P tag and "peoplecontent" - I only want if its not part of another word. 这使我“满意”而没有空格,但同时又带回了P标记和“ peoplecontent”-我只希望它不是另一个单词的一部分。 I need to chain some NOTs together right? 我需要将一些NOT链接在一起,对吗?

使用\\b ,即单词边界元字符,

/\bcontent\b/g

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM