string = "dealing magic damage to enemies she passes through, increased by 0% − 200% (based on target's missing health)."
Why does the following regex not match?
if re.search(r"increased by [-0-9% ]{6,}(based on target's missing health", string):
I’ve tried many variations, but I can’t figure out what I’m doing wrong.
I’ve tried different escape sequences and using a + instead of {6,} on the custom character class, which leads me to another issue I have when I search this pattern with a + on the custom character class it matches to 0% but stops before matching the rest of the – 200%. Any ideas?
Matt Mabry is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
4
r'...'
or r"..."
denote a raw string, meaning that anything inside it is taken as literal string contents. In your case that means that target's
is taken as literal text (the backslash is in the string). Since the target text does not contain a backslash there is no match.