Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import re
  2. pattern = "***abc**de*fg******h"
  3. pattern.replace("*"*, "*")
  4.  
  5. def convertString(pattern):
  6. for i in range(len(pattern)-1):
  7. if(pattern[i] == pattern[i+1]):
  8. pattern2 = pattern[i]
  9. return pattern2
  10.  
  11. re.sub('*+', '*', text)
  12.  
  13. re.sub('**+', '*', text)
  14.  
  15. python27python -mtimeit -s"t='a*'*100;import re" "re.sub('*+', '*', t)"
  16. 10000 loops, best of 3: 73.2 usec per loop
  17.  
  18. python27python -mtimeit -s"t='a*'*100;import re" "re.sub('**+', '*', t)"
  19. 100000 loops, best of 3: 8.9 usec per loop
  20.  
  21. import re
  22.  
  23. result = re.sub("*+", "*", "***abc**de*fg******h")
  24.  
  25. def squeeze(char,s):
  26. while char*2 in s:
  27. s=s.replace(char*2,char)
  28. return s
  29. print squeeze("*" , "AB***abc**def**AA***k")
  30.  
  31. regex = re.compile('*+')
  32. result = re.sub(regex, "*", string)
  33.  
  34. re.sub('*+', '*', pattern)
  35.  
  36. source = "***abc**dee*fg******h"
  37. target = ''.join(c for c,n in zip(source, source[1:]+' ') if c+n != '**')
  38. print target
  39.  
  40. pattern.replace("*"*, "*")
  41.  
  42. pattern.replace("**", "*")
  43. # ^^^^
  44.  
  45. pattern_after_substitution= re.sub(r"*+", "*", pattern)
  46.  
  47. while True:
  48. if " " in pattern:
  49. result = result.pattern(" ", " ")
  50. else:
  51. break
  52.  
  53. File Type : Win32 EXE
  54. File Type Extension : exe
  55. MIME Type : application/octet-stream
  56. Machine Type : Intel 386 or later, and compatibles
  57. Time Stamp : 2017:04:24 09:55:04-04:00
  58.  
  59. File Type : Win32 EXE
  60. File Type Extension : exe
  61. MIME Type : application/octet-stream
  62. Machine Type : Intel 386 or later, and compatibles
  63. Time Stamp : 2017:04:24 09:55:04-04:00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement