Guest User

Untitled

a guest
Aug 17th, 2020
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # regex fix
  2.  
  3. def f(s):
  4.  for e,b in p:
  5.   if b[1:]:s=re.sub(b,f'[{b}{e}]',s)
  6.  for e,b in p:
  7.   if b>b[1:]:s=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s)
  8.  return s
  9.  
  10. # more repeated code
  11.  
  12. def f(s):
  13.  for e,b in p:
  14.   if b[1:]:s=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s)
  15.  for e,b in p:
  16.   if b>b[1:]:s=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s)
  17.  return s
  18.  
  19. # Python 3.8
  20.  
  21. def f(s):
  22.  [(s:=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s))for e,b in p if b[1:]]
  23.  [(s:=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s))for e,b in p if b[1:]<b]
  24.  return s
  25.  
  26. # lambda
  27.  
  28. lambda s:[(s:=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s))for e,b in p if b[1:]]and[(s:=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s))for e,b in p if b[1:]<b][-1]
  29.  
  30. # use repeated code
  31.  
  32. f=eval("lambda s:_]and_<b][-1]".replace('_',"[(s:=re.sub(f'(?<!\[){b}',f'[{b}{e}]',s))for e,b in p if b[1:]"))
RAW Paste Data