I have the following string:
data-event-title="Yuichi Sugita* vs Adrian Mannarino">
You use of dots is "greedy" so they capture as much as they possibly can (and you don't actually want that in this case).
You can change the capture group quantifiers to be "lazy", but it will be more efficient to use negated character classes (syntax
[^character]) for your capture groups.
The dot between your two capture groups is fine to be "greedy" because it will start matching when it encounter
Assuming you have linebreaks as your sample input shows, your dot will stop on newline characters unless you use the
s flag with your pattern. Use this:
This will capture:
data-event-title="ending just before the first occurrence of
class="odds">ending just before the first
Here is the Python regex pattern demo.
If you want the full
data-event-title attribute value, this will capture
Yuichi Sugita* vs Adrian Mannarino: