regEx works in notepad++ but not in python
Question: let's say we have this:

    
    
    .................
    === Operation 'abcd::ddca:dsd' ended in 1.234s   /1.234s (100.00%) execution time
    ................
    

Using notepad++, I am able to identify this with:

    
    
    ^\=* Operation '([\d\D]*)' ended in (\d*.\d*)s\s*/(\d*.\d*)s \([\d\D]*\) execution time
    

I want the operation name and execution times to be grouped.

In python, trying this:

    
    
    exp=re.compile(r"^\=* Operation \'([\d\D]*)\' ended in (\d*.\d*)s\s*/(\d*.\d*)s \([\d\D]*\) execution time") 
    

provides nothing. I've tried `\\(` for escaping the literal paranthesis but it
didn't work. I'm guessing I don't need to do that since I'm using r"[exp]"
when building the object expression.

Any ideas on how to get the same result as in notepad++?

**LE: tried only with:**

    
    
    exp=re.compile(r"^\=* Operation \'([\d\D]*)\'", flags=re.MULTILINE)
    

still doesn't find anything.

**LE2:**

later in the code I'm using `groups=exp.match(INPUT)` and I get the pairs with
`groups.group(n)`

ANSWER: the problem was `match`. Using `search` **fixed the problem**


Answer: The regular expression mentioned in the question is working for me without any
change.

    
    
    >>> s = """
    ... .................
    ... === Operation 'abcd::ddca:dsd' ended in 1.234s   /1.234s (100.00%) execution time
    ... ................
    ... """
    >>> import re
    >>> exp = re.compile(r"^\=* Operation \'([\d\D]*)\' ended in (\d*.\d*)s\s*/(\d*.\d*)s \([\d\D]*\) execution time", flags=re.M)
    >>> re.search(exp, s)
    <_sre.SRE_Match object at 0x1038766b8>
    >>> re.findall(exp, s)
    [('abcd::ddca:dsd', '1.234', '1.234')]
    

Two things to consider though:

  1. Use `re.M` in the flags argument
  2. User `search` or `findall` method to do the matching. Make sure you are not using `re.match` because it will match only the beginning of the string.

