Here is my regex pattern: [Ss]ection\s\d+(?![a-zA-z])(?!</ref>)
For example, it should match: section 5 or section 50
For example, it should not match: section 5A or section 5</ref> or section 5A</ref> or section 50A
Problem is that in reality it matches them wrong: http://regexr.com?33ien
Not sure what’s wrong with the pattern though…
Maybe try
[Ss]ection\s\d++(?![a-zA-z])(?!</ref>). ++ is possessive quantifier. This quantifier is similar to greedy quantifier except it blocks fragment of string that it matched from being used by later part of regex.Example