I want to search for occurrences of ad and abcd where the bc is optional.  How can I do that?  i.e.,
+-------+----------+ | ad    | MATCH    | | abcd  | MATCH    | | abd   | NO match | | abbd  | NO match | | abced | NO match | | abcbcd| NO match | +-------+----------+ 
                Solutions:
 option 1: ad\|abcd
 option 2: a\(bc\)\=d
 option 3: a\(bc\)\?d
Close but not quite:
 option 4: a\(bc\)\{-\}d (zero or more; matches abcbcd which is not desired)
Descriptions:
+--------+--------------------------+ | \|     | logical OR (alternation) | | \(bc\) | treat `bc` as a group    | | \=     | zero or one occurrences  | | \?     | zero or one occurrences  | | \{-\}  | zero or more occurrences | +--------+--------------------------+ 
                        well, I maybe stupid, but if the requirement is
search for occurrences of ad and abcd where the bc is optional.
why not  simply and straightforward /ad\|abcd?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With