fork download
  1. import re
  2.  
  3.  
  4. def clean(texte):
  5. regex = r"\[\[[^]]+\]\]|\w+"
  6. s_tab = []
  7. res = re.findall(regex, texte)
  8. for i in range(len(res)):
  9. if len(res[i]) >= 4:
  10. s = res[i]
  11. if "[" not in s:
  12. s.lower()
  13. s_tab.append(s)
  14. res = ' '.join(s_tab)
  15. return res
  16.  
  17. s1 = "[[Fichier:Euclid flowchart 1.png|vignette|[[Flowchart]] of an algorithm ([[Euclid's algorithm]]).]]"
  18. s2 = "blablablabla this \" is \' \' (yes) not a link. This is a link [[Al-Andalus|andalou]] and this [[Babylone|Babyloniens]] is a link with a pipe in it."
  19. print(clean(s1+s2))
Success #stdin #stdout 0s 23296KB
stdin
Standard input is empty
stdout
[[Fichier:Euclid flowchart 1.png|vignette|[[Flowchart]] algorithm [[Euclid's algorithm]] blablablabla this link This link [[Al-Andalus|andalou]] this [[Babylone|Babyloniens]] link with pipe