Imagine I have a string that begins abc in the first three characters, but then ends with either def or xyz. If I wanted to write a regex to match these I would write the following... however, can someone show me how to use OR (|) such that it can go abc(def|xyz) as I can't seem to make it work :(
m/abcdef|abcxyz/
Surely I don't need to duplicate the abc bit twice as although it seems trivial here, in more complex apps it could lead to much bigger regexes?
In reply to Using OR () in Regex by arunhorne
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |