Skip to content Skip to sidebar Skip to footer

Regular Expression To Match Text Outside Html Tags And Not Between Specific Tag

I trying to get a regular expression to match some words outside and between html tags (and not in tags themselves), but I also need to exclude them when they are between html head

Solution 1:

use this pattern to skip/ fail everything between <h1></h1> Updated per comment below

<h1>[^<>]*<\/h1>(*SKIP)(*F)|(\bsample|text\b)(?=[^>]*(?:<|$))  

Demo

Post a Comment for "Regular Expression To Match Text Outside Html Tags And Not Between Specific Tag"