0

I have this regex to find and replace : ; ? !

/(\u00AB|\u2014)(?:\s+)?|(?:\s+)?([\?!:;\u00BB])/g

but I'd like to ignore the characters within a style tag i.e <a style='font-weight:bold'>

Regex to ignore (?!.style=\".*\") How do I accomplish that?

bobble bubble
  • 16,888
  • 3
  • 27
  • 46
emilevirus
  • 17
  • 4
  • You really can't, because you can't tell with a regex if you're "in a style tag". – Andy Lester Sep 20 '22 at 13:30
  • You _really_ don't want to use regexes to parse HTML. https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – sniperd Sep 20 '22 at 13:39
  • Example to match `[:;?!]` outside angle brackets: [`[:;?!](?![^><]*>)`](https://regex101.com/r/sQQCbl/1) (explanation on right side). – bobble bubble Sep 20 '22 at 14:24

0 Answers0