string = "Daneshwar$/?$Daneshwar" regex = re.compile('[@_!#$%^&*()<>?/|}{~:]') if(regex.search(string) == None): print("special is absent") else: print("present")