I'm used to doing Regex's in a variety of languages, but I don't know Python well.
I'm looking for a regex that will do the same as the following JavaScript regex:
(disc|dis|se|oti)(\d+)\W
i.e. where the string will consist of one of those 4 strings followed by one or more digits followed by a space. This string will appear at the very beginning of the string (so I can use re.match rather than re.search).
It looks like I can use this:
re.match( r'(disc|dis|se|oti)(\d+)\s', line)
but should I be using the 'r' at the beginning?
re.match( r'(disc|dis|se|oti)(\d+)\W', line)if you want. If you're trying to match anywhere in a string, then usere.searchinstead ofre.match.