Strings and Character

Check Special Character

# āļ•āļĢāļ§āļˆāļŠāļ­āļšāļ§āđˆāļēāļ‚āđ‰āļ­āļ„āļ§āļēāļĄāļ”āļąāļ‡āļāļĨāđˆāļēāļ§āļĄāļĩāđ„āļĄāđˆāļĄāļĩāļ­āļąāļāļ‚āļĢāļ°āļžāļīāđ€āļĻāļĐāļŦāļĢāļ·āļ­āđ„āļĄāđˆ (āđ„āļĄāđˆāļĄāļĩ return = True)

# import required package 
import re 
  
# Function checks if the string 
# contains any special character 
def check_special_char(string): 
  
    # Make own character set and pass  
    # this as argument in compile method 
    regex = re.compile('[@_!#$%^&*()<>?/\|}{~:]') 
      
    # Pass the string in search  
    # method of regex object.     
    if(regex.search(string) == None): 
        return True 
          
    else: 
        return False 

Last updated