Input Output --------------------------------------- 'x|xy' 'xy?' 'xx|xyx' 'xy?x' 'a|abc' 'a(bc)?' 'a|ab|abc' 'a(b(c)?)?' 'a1|a2|a3' 'a[123]' #### /that|this|thinks|thirst|three/ -> /th(at|i(?:(?:nk)?s|rst)|ree/ ? -> /th(?:at|is|inks|irst|ree)/ ? -> /th(?:at|i(?:nk)?s|irst|ree)/ ?