In Java regexes, you can use the intersection operator && in character classes to define them succinctly, e.g.
[a-z&&[def]] // d, e, or f
[a-z&&[^bc]] // a through z, except for b and c
Is there an equivalent in JavaScript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple answer: no, there’s not. It is specific Java syntax.
See: Regular Expressions Cookbook by Jan Goyvaerts and Steven Levithan. Here’s a sneak-peek to the relevant section.
Probably needless to say, but the following JavaScript code:
would do the same as the Java code: