Example >> INPUT : myStr = "Legal Counsel 3 - 8 yrs' PQE" >> CODE : import re def apply_operation(title): title = unicode(title.lower().strip()) // if not work so just remove unicode title = title.replace('&','') title = re.sub(r'(?s)\s+', r'-', title) title = re.sub(r"(?s)[^a-z-0-9]",r"-", title) title = re.sub(r'(?s)\-{2,}', r'-', title) return title result = apply_operation(myStr) print(result) >> OUTPUT : legal-counsel-3-8-yrs-pqe >> Additional Note : Add the following code if you want to convert non-english to english characters with "import unicodedata" module. unicodedata.normalize('NFKD', title).encode('ASCII', 'ignore')