Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- pattern = "***abc**de*fg******h"
- pattern.replace("*"*, "*")
- def convertString(pattern):
- for i in range(len(pattern)-1):
- if(pattern[i] == pattern[i+1]):
- pattern2 = pattern[i]
- return pattern2
- re.sub('*+', '*', text)
- re.sub('**+', '*', text)
- python27python -mtimeit -s"t='a*'*100;import re" "re.sub('*+', '*', t)"
- 10000 loops, best of 3: 73.2 usec per loop
- python27python -mtimeit -s"t='a*'*100;import re" "re.sub('**+', '*', t)"
- 100000 loops, best of 3: 8.9 usec per loop
- import re
- result = re.sub("*+", "*", "***abc**de*fg******h")
- def squeeze(char,s):
- while char*2 in s:
- s=s.replace(char*2,char)
- return s
- print squeeze("*" , "AB***abc**def**AA***k")
- regex = re.compile('*+')
- result = re.sub(regex, "*", string)
- re.sub('*+', '*', pattern)
- source = "***abc**dee*fg******h"
- target = ''.join(c for c,n in zip(source, source[1:]+' ') if c+n != '**')
- print target
- pattern.replace("*"*, "*")
- pattern.replace("**", "*")
- # ^^^^
- pattern_after_substitution= re.sub(r"*+", "*", pattern)
- while True:
- if " " in pattern:
- result = result.pattern(" ", " ")
- else:
- break
- File Type : Win32 EXE
- File Type Extension : exe
- MIME Type : application/octet-stream
- Machine Type : Intel 386 or later, and compatibles
- Time Stamp : 2017:04:24 09:55:04-04:00
- File Type : Win32 EXE
- File Type Extension : exe
- MIME Type : application/octet-stream
- Machine Type : Intel 386 or later, and compatibles
- Time Stamp : 2017:04:24 09:55:04-04:00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement