wtorek, 25 kwietnia 2017

Python regexp example

import re
exampleString = '''My Name is Marek Borkowski and i have 34 years old'''
ages = re.findall(r'\d{1,3}',exampleString)
print(ages)
names = re.findall(r'[A-Z][a-z]*',exampleString)
print(names)

ansible-> python regexp.py
['34']
['My', 'Name', 'Marek', 'Borkowski']

Brak komentarzy:

Prześlij komentarz