Utilizor
Contact Us

Python RegEx

Regular Expressions.

Examples

Search

Search for a match.

import re

txt = "The rain in Spain"
x = re.search("^The.*Spain$", txt)

if x:
  print("YES! We have a match!")
else:
  print("No match")

Findall

Returns a list containing all matches.

import re

txt = "The rain in Spain"
x = re.findall("ai", txt)
print(x)

Test Your Knowledge

Python Quiz

No quiz available for this topic yet.