Regex help

I have a regex expression that matches with ampersand extended characters like   etc.
Code:
&[^ ;]+;

However, this also matches with some extended text characters, e.g. â (â) which I want to allow.

How do I add a whitelist to the expression to allow this, and a few others? Need to exclude all **acute, **circ, **grav and **uml

Something like
Code:
(&[^ ;]+;)(?!&[AaEeIiOoUuYy]+(acute|circ|grav|uml)+;)
although I seem to be getting intermittent results testing this.

Many thanks.
 

gregatron5

Ars Legatus Legionis
13,011
Subscriptor++
I have a regex expression that matches with ampersand extended characters like   etc.
Code:
&[^ ;]+;

However, this also matches with some extended text characters, e.g. â (â) which I want to allow.

How do I add a whitelist to the expression to allow this, and a few others? Need to exclude all **acute, **circ, **grav and **uml

Something like
Code:
(&[^ ;]+;)(?!&[AaEeIiOoUuYy]+(acute|circ|grav|uml)+;)
although I seem to be getting intermittent results testing this.

Many thanks.
On my iPad, so no testing, but try moving the negative look ahead to right after the first ampersand
Code:
(&(?![AaEeIiOoUuYy]+(acute|circ|grav|uml))[^ ;]+;)