I'm new to Python and to Regex. Here is my current problem, for which I have not managed to find any straight answer online. I have a string of 5 or more characters, for which I need to search for all the possible combinations of 5 characters.
I wonder if it's doable with regular expressions (instead of, say, creating a list of all possible 5-character combinations and then testing them in loop with my string).
For example, let's say my string is "stackoverflow", I need an expression that could give me a list containing all the possible combinations of 5 successive letters, such as: ['stack', 'tacko', ackov', ...]. (but not 'stcko' or 'wolfr' for example).
That's what I would try:
import re
word = "stackoverflow"
list = re.findall(r".....", word)
But printing this list would only give:
['stack', 'overfl']
Thus it seems that a position can only be matched once, a 5-character combination cannot concern a position that has already been matched.
Could anyone help me better understand how regex work in this situation, and if my demand is even possible directly using regular expressions?
Thanks!