Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. [/<>*?|:"~#%&{}\]+
  2.  
  3. Str/|ng
  4.  
  5. def cleanPath(path):
  6. #Compiling regex...
  7. multi_dot = re.compile(r"[.]{2,}")
  8. start_dot = re.compile(r"^[.]")
  9. end_dot = re.compile(r"[.]$")
  10. disallowed_chars = re.compile(r'[/<>*?|:"~#%&{}\]+')
  11. dis1 = re.compile(r'.files$')
  12. dis2 = re.compile(r'_files$')
  13. dis3 = re.compile(r'-Dateien$')
  14. dis4 = re.compile(r'_fichiers$')
  15. dis5 = re.compile(r'_bestanden$')
  16. dis5 = re.compile(r'_file$')
  17. dis6 = re.compile(r'_archivos$')
  18. dis7 = re.compile(r'-filer$')
  19. dis8 = re.compile(r'_tiedostot$')
  20. dis9 = re.compile(r'_pliki$')
  21. dis10 = re.compile(r'_soubory$')
  22. dis11 = re.compile(r'_elemei$')
  23. dis12 = re.compile(r'_ficheiros$')
  24. dis13 = re.compile(r'_arquivos$')
  25. dis14 = re.compile(r'_dosyalar$')
  26. dis15 = re.compile(r'_datoteke$')
  27. dis16 = re.compile(r'_fitxers$')
  28. dis17 = re.compile(r'_failid$')
  29. dis18 = re.compile(r'_fails$')
  30. dis19 = re.compile(r'_bylos$')
  31. dis20 = re.compile(r'_fajlovi$')
  32. dis21 = re.compile(r'_fitxategiak$')
  33. regxlist = [multi_dot,start_dot,end_dot,disallowed_chars,dis1,dis2,dis3,dis4,dis5,dis5,dis6,dis7,dis8,dis9,dis10,dis11,dis12,dis13,dis14,dis15,dis16,dis17,dis18,dis19,dis20,dis21]
  34. print("************************************nn"+path+"nn************************************n")
  35. for x in regxlist:
  36. match = x.search(path)
  37. if match:
  38. print("n")
  39. print("MATCHED")
  40. print(match.group())
  41.  
  42. print("___________________________________________________________________________")
  43. return path
  44.  
  45.  
  46. #testlist of conditions that should be found, some OK, some bad
  47. testlist = ["string","str....ing","str..ing","str.ing",".string","string.",".string.","$tring",r"string","st/r/ing",r"str/|ng","/str<i>ng","str.filesing","string.files"]
  48. testlist_ans = ["OK","Match ....","Match ..","OK","Match .","Match .","Match . .","OK",r"Match ","Match /",r"Match /|","Match / < >","OK","Match .files"]
  49. count = 0
  50. for i in testlist:
  51. print(testlist_ans[count])
  52. count = count + 1
  53.  
  54. cleanPath(i)
  55.  
  56. re.sub(pattern,new_txt,subject) #replace all instinces of pattern with new_txt
  57. re.findall(pattern,subject) #find all instances
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement