Java[^script]
We have a regexp /Java[^script]/.
Does it match anything in the string Java? In the string JavaScript?
Answers: no, yes.
-
In the script
Javait doesnt match anything, because[^script]means any character except given ones. So the regexp looks for"Java"followed by one such symbol, but theres a string end, no symbols after it. -
Yes, because the
[^script]part matches the character"S". Its not one ofscript. As the regexp is case-sensitive (noiflag), it treats"S"as a different character from"s".