regex match several words
# To match the entire line which contains one of foo, man, choo:
^.*(foo|man|choo).*$
regex match several words
# To match the entire line which contains one of foo, man, choo:
^.*(foo|man|choo).*$
Multiple sub in single regex
# Multiple sub in single regex.
import re
class Substitutable(str):
def __new__(cls, *args, **kwargs):
newobj = str.__new__(cls, *args, **kwargs)
newobj.sub = lambda fro,to: Substitutable(re.sub(fro, to, newobj))
return newobj
h = Substitutable('horse')
h = h.sub('h', 'f').sub('e','h')
print(h)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us