If I have a text line such as “so and so bit mike” where so and so could be any group of words with any group of spaces in it, what would a regular expression look like that would match
“so and so bit mike” but not “so and so really bit mike”
The only way I can think of to match so and so is .*, but .* (?!really)bit mike still matches.
Please note, for my purposes I need this to work with a single regex expression.
.* (?!really)bit mikematches. in fact your negative lookahead is useless there because you’re basically saying the next six characters must not be “really”, but then you state that they must be “bit mi”. No string can match “bit mi” and “really” at the same time so if:.* bit mikematches a string then so does.* (?!really)bit mikeI don’t know if this is the simplest way, but try using a negative lookbehind instead of a lookahead:
.*(?<!really) bit mikeWhich says that the be six characters before
bit mikewhich cannot be the string really