Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python - regexp to find part of an email address

# Visit: https://regexr.com/
# and look at the Menu/Cheatsheet
import re

# Extract part of an email address
email = 'name@surname.com'

# Option 1
expr = '[a-z]+'
match = re.findall(expr, email)
name = match[0]
domain = f'{match[1]}.{match[2]}'

# Option 2
parts = email.split('@')
Comment

regex find email address in string python

import re
x = 'Imagine this is the email address: 6775.love@everywhere.com'
y = re.findall('S+@S+', x)
# according to the expression it will look for a string with @ sign
# and which starts and end with a space
print(y)            # Output: ['6775.love@everywhere.com']
Comment

PREVIOUS NEXT
Code Example
Python :: xgboost algorithm in python 
Python :: find value in dictionary python 
Python :: matplotlib documentation download via 
Python :: how to check if number has decimals python 
Python :: pandas como eliminar filas con valores no nulos en una columna 
Python :: insert column in a dataframe 
Python :: loading in pyqt5 
Python :: tuple and list in python 
Python :: termcolor print python 
Python :: depth first search python recursive 
Python :: pandas groupby values in list 
Python :: python dict comprehension 
Python :: pandas .nlargest 
Python :: get number of key in dictionary python 
Python :: matplotlib figure size not working 
Python :: How to read PDF from link in Python] 
Python :: python print n numbers 
Python :: create a empty dataframe 
Python :: csv len python 
Python :: python possible combinations 
Python :: iterating through a list in python 
Python :: list element swapping python 
Python :: only read some columns from csv 
Python :: python regular expression 
Python :: python string cut first n characters 
Python :: nonlocal keyword python 
Python :: python access key in dictionary 
Python :: conda create environment python 3 
Python :: Tensor.expand_as 
Python :: python ffmpeg get video fps 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =