Just use search() method and it will stop at the first match.
The python uses
import re
re.search(r'somepattern', string)