Your logic is backwards. When
A != B || A != C
then this will evalutate to
true unless
B == C
A = 2
B = 2
C = 3
A != B => false
A != C => true
false || true => true
You want to use
&&
instead.
You also might want to check your regexes:
1) the match expression should not be enclosed in quotes
2) you seem to have a stray backslash before the R in the second clause
3) There's no right-hand anchor (
$) for either term, so it will match
R99.9a
. For example your simple case would be
/^R\d+\.\d+$/
4)
\w
includes the underscore, so you don't need to add it to the character class
5) Although you don't say so, you may need to start the complex pattern with a letter. In this case the pattern should start with
/^[A-Za-z]...