user1651157
user1651157

Reputation:

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?

Upvotes: 1

Views: 139

Answers (1)

Himanshu
Himanshu

Reputation: 2454

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

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

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

Upvotes: 1

Related Questions