get all special char from string in python by R4R Team

Example-

String is s="HEllo #world!"

Aim-
-To get special character from the string , so this return [' ','#','!']


program-

#import the re module
import re

#take input of string
print("Enter string")
s=input()

#fill all special character from the string
x=re.findall('W',s)
print("Special Character that are present in string :",x)


output-

Enter string
Hello #world!-
Special Character that are present in string : [' ', '#', '!', '-']

Enter string
#$%^&*123
Special Character that are present in string : [' ', '#', '$', '%', '^', '&', '*']

Enter string
string123
Special Character that are present in string : []


-In this program, we take a input of string and find all special character in the string by using re.findall() function where 'W' is the meta sequence which are inform about the special character.




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!