Skip to content

Commit 3a6ede2

Browse files
committed
added new code snippet
1 parent 1be2bb4 commit 3a6ede2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import re
2+
def remove_special_characters(input_string):
3+
4+
result_string = ''.join(filter(str.isalnum, input_string))
5+
return result_string
6+
7+
print(remove_special_characters('abcd&*gshshs'))
8+
print(remove_special_characters('atif'))
9+
print(remove_special_characters('mohd atif'))
10+
11+
def remove_special_characters_regex(input_string):
12+
result_string = re.sub(r'[^a-zA-Z0-9\s]', '', input_string)
13+
return result_string
14+
15+
print(remove_special_characters_regex('abcd&*gshshs'))
16+
print(remove_special_characters_regex('atif'))
17+
print(remove_special_characters_regex('mohd atif3'))

0 commit comments

Comments
 (0)