re.compile("abc")
I would like to do "abc" OR "xyz".
re.compile("abc")
I would like to do "abc" OR "xyz".
Use |
:
re.compile("abc|xyz")
It's worth perusing regular-expression.info for detailed information as well as Regular Expression HOWTO and re — Regular expression operations from the Python documentation.
I'll take this opportunity to point you to an excellent reference for many of life's problems: Wikipedia.
Regular Expressions on Wikipedia
You might also find answers here.
I'm more a perl regex guy, but the current popular answer seems to match either abcyz or abxyz. I normally would have the regex look like "(abc)|(xyz)". You want to use the parenthesis to group the 2 strings your looking for.
Remember the doc property inside of python. In particular, you can access it for regex by typing
import re
re.__doc__
at the python shell or by using a python doc browser such as the one built into Spyder.
This particular question is addressed there.