I'm using Perl by supplying the flag boost::regex_constants::perl when building my pattern.
Yes, I have compiled my string and it only finds cases with digits or '&'.
Duoas, thanks for the fragment and you're right, it would match the entirety of text. What I'm ultimately trying to do is remove something like ", Room A&1" from "Anyplace, Room A&1", but not remove ", Room A" because the room designator is only alphabetic.
The following regex will match any contiguous range of chars following Room and some leading, internal and trailing white space/punctuation, but it doesn't enforce the presence of at least one non-alphabetic character in the room number:
(^|[ ,-]+){1}Room[ .,-]+[A-Za-z0-9&]+[ ,-]*
Before/After using boost::regex_replace(txt, pattern, "")
Science Hall Room - A&B -
Science Hall
Room 1C, Science Hall
Science Hall
Room C, Science Hall
<no change, as desired>
I think I need to AND sub-expressions to add an addtional condition like ([^A-Za-z]){1} that will also ensure at least one of those contiguous characters is non-alphabetic:
Thanks for sticking with me on this. The variable makeup of the room "number" is what is tripping me up. It could be a combination of letters, numbers or punctuation like &, but not necessarily include all of those types, and not in any particular order. Here is a sample of the variety of strings I'm trying to match and the desired results:
anytext, Room Abc
anytext, Room - Abc
Room xyz,- anytext
<no change as room number is only alphabetic)
I now see that password validation expressions do something similar to what I want, but they are designed to suck up all the given text. I should probably take one of those and try to change it to limit the scope of text it matches to just the room "number".
Thanks Duoas, that helps a lot! I was trying too hard to logically AND sub-expressions to check for at least one non-alphabetic char, but this is simpler and works great for boost C++ regexes in Visual Studio.