I am receiving an error on the .match regex module function of TypeError: An integer is required.
Here is my code:
hAndL = hAndL.replace('epsilo\ell','epsilon')
pattern = re.compile("\frac{.*?}{ \frac{.*?}{.*?}}")
matching = pattern.match(pattern,hAndL)
hAndL is a string and pattern is a..pattern.
I'm not sure why this error is happening, any help is appreciated!
When you re.compile
a regular expression, you don't need to pass the regex object back to itself. Per the documentation:
The sequence
prog = re.compile(pattern) result = prog.match(string)
is equivalent to
result = re.match(pattern, string)
The pattern
is already provided, so in your example:
pattern.match(pattern, hAndL)
is equivalent to:
re.match(pattern, pattern, hAndL)
# ^ passing pattern twice
# ^ hAndL becomes third parameter
where the third parameter to re.match
is flags
, which must be an integer. Instead, you should do:
pattern.match(hAndL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With