Reputation: 1224
I currently have a regular expression that allows for the string 'red' in lowercase, uppercase and with spaces surrounding it:
/red/i
How would this regular expression be extended to check for multiple words such as rot, rouge, red and rojo.?
I am using a Javascript plugin which does not support flags. This regex also takes the same form in JavaScript in a none literal format, how would this be extended in the same way?
^\s*[Rr][Ee][Dd]\s*$
Upvotes: 0
Views: 348
Reputation: 5934
There are many dialect's of regular expressions. However, in this case the following would work in most cases:
/red|green|yellow|blue/i
Upvotes: 0
Reputation: 521103
Try using the OR operator in your regex:
/(blue|green|red)/i
Upvotes: 1