Please share the your requirement-screenshot or your code?
Are you doing this in scripting or in the find/change dialog box?? If scripting, all the backslashes need to be escaped. If not then it's fine; you just need to add a possibility of a hyphen -? between two sets of letters.
Don't use alternative inside character classes. Use whis to match words that can be hyphenated:
Can you provide an example?? I tried to recreate this but for me both cases work:
app.findGrepPreferences = app.changeGrepPreferences = null; app.findGrepPreferences.findWhat = "\\<and\\b"; app.changeGrepPreferences.changeTo = "AND"; app.changeGrep();
Except when scripting without using Find/Change preferences.. Then neither worked:
if(app.selection.contents == "\bAND\b"); alert("YES");