You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The .format is just building a string that will be used as a pattern. If the resulting string is not a valid pattern, then the module will complain when it tries to compile it.
Whatever you have in substring is not a valid pattern.
@mrabarnett
actually I was passing the substring pattern which is starting with * but i didn't mean to use it as regex character and after i used the re.escape()
matches = re.finditer(r"\b{}\b".format(re.escape(substring)), string)
OFFSETS = [(_.start(), _.end()) for _ in matches ]
the error gone but no matching came even the substring already exists in the string
ex:
substring = '*Hello'
String = "*Hello world"
why no matching came even the substring exists in the string ?
The pattern you're building is \b\*Hello, which will match a word boundary, then a *, then Hello. The string you have starts with a *, followed by Hello. There's no word boundary before the *.
I am facing this issue when i am trying to loop on certain expressions to find their occurences in string
I am using the last version of the package
here is the code
the error occurs in the line where i use finditer
it says
re.error: nothing to repeat at position 0
The text was updated successfully, but these errors were encountered: