Alternations

Sometimes, you need a regular expression to match different possible words or character strings. This is possible by using the alternation metacharacter (|). So, if you want to match any substring that contains the word hi or the word hello, then use the following expression:
	'/hi|hello/'
	
Bear in mind that the expression tries the alternative choices from left to right trying to match the regular expression at the earliest possible point in the string. The following are some examples:
	"black and white".contains('/black|gray|white/') 
	    // matches black 
	"black and white".contains('/white|gray|black/')  
	    // matches black. Even though white is the first 
	    // alternative in the string, black matches 
	    // earlier in the string. 
	"Bye!".contains('/b|by|bye|bye!/i') 
	    // matches b 
	"Bye!".contains('/bye!|bye|by|b/i') 
	    // matches bye! 
	

The last example suggests that if some of the alternatives are prefixes of the others, they put the longest alternatives first. Otherwise, they will never match.

In some way, you can think of character classes as character alternations. So '/[aeiou]/' behaves like '/a|e|i|o|u/'.