Using the && operator in a character class

Viewed 92

Something like this works in Ruby but not in Javascript:

str = "now is the time"
p str.gsub(/[a-z&&[^aeiou]]/, '*')

Notice the && on the second line.

[a-z&&[^aeiou]] works but if you remove the [] around the whole regex and have a-z&&[^aeiou] it won't work. Why? Is this unique to Ruby only? I haven't been able to find much info about this feature.

2 Answers
Related