Is there a way to use the negative mark outside of a set?

Let’s say I have the following series:
Series = ['Java', 'JavaScript', 'Javascript', 'JavaSon', 'Javason', 'JavaSister', 'Javasister']

And I want to match anything that starts with ‘Java’ in this series except ‘JavaScript’ and ‘Javascript’.
Is there a way to use the ^ mark outside of a [ ] set for this case?
If so, how do I do that?

You should be able to use negative lookahead (?!) in conjunction with the rest of your expression.

Something like - your_expression(?![Ss]cript)

That (?![Ss]cript) part essentially should help ignore those two words.

I haven’t tested it out myself, so I can’t provide the entire solution. So, you might have to experiment a bit with it.


Ah gotcha! Thanks for answering!

1 Like