I'm trying to find all instance of an acronym outside enclosing parenthesis; e.g., I'm looking for FO, but not (FO). While the term can be defined as an acronym; e.g., Faint Objects (FO), the acronym is only used in specific instances (FO I/FO II). Except for these instances, the acronym needs to be spelled out in the document.
To complicate it, I also need to find instances where the acronym is used in a parenthetical phrase; e.g., (FO are hard to see) and (like non-FO). In these instances, the acronym also needs to be spelled out.
I tried:
(?<!\x28)HQ(?!\x29)
Which works well except for (FO are hard to see); i.e., acronym preceded by parenleft.
Usually, it's rendered un-ambigous like this :
https://regex101.com/r/Rkz9oN/1
This uses a compound nested assertion.
Note that: If using the new JS engine with variable length look behind
the
FOcan be variable and used as a back reference :https://regex101.com/r/jxFSmX/1
This facilitates finding multiple Acronyms in a single regex guarded by this assertion :
https://regex101.com/r/OCEmNy/1
In-fact you can have every single Acronym you can type or cut'n paste) put into a trie regex generator (https://regexformat.com/scrn8/TernSort.jpg) making it a formidable tool.