given string “abcdefgh” how do I match all strings starting with “abcde”, whose do not end in “fgh”?
More generic task – match string startin with certain common pattern but do not end in any of pre-defined (exclusion) patterns.
"\babcde(^fgh)\b"
doesn’t work
if the needed prefix and the excluded suffix may not overlap, you can use a negative lookahead. By “strings”, I assume you mean “words”:
If the prefix and suffix may overlap, move the lookahead to the front
If by “strings” you mean “strings”, use the
^and$as the boundary conditions:If you want to get the match as well, rather than just test the string, include “the rest of the string” to the regex: