'regex python for matching exact number of characters with overlapping matches
For example, I have a a string t = "abftababcd"
I want to match a pattern p= "abXX"
where X is a wild card and matches any character. For the given p and t I want to get ['abft', 'abab','abcd']
For p="XXab" the expected output is ['ftab', 'abab']
Now i want to match all the overlapping matches in string t. I have tried replacing X with "ab\w{no.of X}"
This doesn't give overlapping matches. So i tried lookahead assertion as"ab(?=(\w{no.of X}))"
Then this only gives me the matches with the pattern "ab". Also, does lookahead work if X is present in the beginning XXab of the string or in the middleaXXXb?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
