Last active
December 25, 2017 07:47
-
-
Save LiVanych/30c36164627a14f1b600296e9c90b84a to your computer and use it in GitHub Desktop.
[Regular Expressions] How it work. #python #module #re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import re | |
numberslist = ["818-262-4549","232-232-2323","244-235-9999"] | |
numbers = re.compile("\d{3}-\d{3}-\d{4}") | |
for number in numberslist: | |
log = numbers.search(number) | |
print(log.group()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import re | |
s = 'Hello!@#!%!#&&!*!#$#%@*+_{ world!' | |
reg = re.compile('[^a-zA-Z ]') | |
print(reg.sub('', s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment