Skip to content

Instantly share code, notes, and snippets.

@LiVanych
Last active December 25, 2017 07:47
Show Gist options
  • Save LiVanych/30c36164627a14f1b600296e9c90b84a to your computer and use it in GitHub Desktop.
Save LiVanych/30c36164627a14f1b600296e9c90b84a to your computer and use it in GitHub Desktop.
[Regular Expressions] How it work. #python #module #re
#! /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())
#! /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