# 10 20 30 40 50 # ---------'---------'---------'---------'---------'---- my $str = "& ... & ... & ... &no_entity; ... & ... ;"; while ($str =~ /&(?!#?[0-9a-z]+;)/gi) { print "Found ampersand at position ".pos($str)."\n"; } #### Found ampersand at position 32 Found ampersand at position 48