[^abc] Any single character except: a, b, or c
But how can I make regex for any characters except sequence abc
So, something like that
"Hello abc awesome world".scan /[^(abc)]+/
Will return “Hello ” and ” awesome world”.
PS: And it is not about splitting the string
This is called lookaround, in your case you’ll want to use negative lookahead. I’m not sure about the exact syntax in Ruby, but something along
(?!abc)might work. Note that the lookaround doesn’t consume any input, so you’ll need to have this followed by any pattern that you do want to match. Perhaps(?:(?!abc).)+is what you’re looking for?