We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
The regexes I saw can be shortened using either a positive lookbehind or a positive lookahed. I don't think it can be solved without them because you have to avoid consuming the input somewhere (before or after).
Using the positive lookbehind:
import re
v = "aeiou"
c = "qwrtypsdfghjklzxcvbnm"
m = re.findall(r"(?<=[%s])([%s]{2,})[%s]" % (c, v, c), input(), flags = re.I)
print('\n'.join(m or ['-1']))
Using the positive lookahead, same as above with the regex:
Re.findall() & Re.finditer()
You are viewing a single comment's thread. Return to all comments →
The regexes I saw can be shortened using either a positive lookbehind or a positive lookahed. I don't think it can be solved without them because you have to avoid consuming the input somewhere (before or after).
Using the positive lookbehind:
Using the positive lookahead, same as above with the regex: