Reputation:
So I know (.)\1
is the format for finding consecutive characters with a regular expression, but I've noticed it is case sensitive, so it won't pick up "sS"
or "hH"
on a text field or string.
How would I change this, and also how would I implement it using python 3.5 with the re.findall
method?
Upvotes: 1
Views: 718
Reputation: 212895
Add re.IGNORECASE
:
re.findall(r'(.)\1', 'aA', re.IGNORECASE)
to match strings like aA
.
Docs: https://docs.python.org/2/library/re.html#re.IGNORECASE
Upvotes: 4
Reputation: 5337
You should ignore the case like this:
re.IGNORECASE
https://docs.python.org/2/library/re.html
Upvotes: 1