简体   繁体   中英

Regex to find the text without a special character

I have a paragraph, in that, some of the texts are surrounded with a specific html tag. I need to to find the text which are not surrounded by that specific html tag. For example

AVG Antivirus for Smartphones and Tablets detects harmful apps and SMS. 

<font color='black'>AVG</font> Mobilation™ AntiVirus Pro for Android™ is a mobile security 

solution that helps protect your mobile device from viruses, malware, spyware and online 

exploitation in real-time. avg blah blah...

I want to find the word AVG (case insensitive) which is not surrounded by <font color='black'> </font> . It can be part the word or single whole word. In the case of part of the text, the whole word containing the word AVG should not surrounded by that html tag

How can I do it with Java?

See http://www.regular-expressions.info/lookaround.html#limitbehind

You can try following in case you haven't already :-

(?<!<font color='black'>)AVG(?!</font>)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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