Ejercicio de RegEx #0: Existencialismo

Escribe tres expresiones regulares: una llamada "nothing" que coincida únicamente con una cadena vacía, una llamada "anything" que coincida con cualquier cadena, vacía o no, y una llamada "something" que coincida solo con cadenas no vacías.

Ejemplo

txt1 = ""
txt2 = "This is not an empty string."

nothing = "yourregularexpressionhere"
anything = "yourregularexpressionhere"
something = "yourregularexpressionhere"

bool(re.match(nothing, txt1)) ➞ True
bool(re.match(nothing, txt2)) ➞ False
re.findall(nothing, txt1) ➞ [""]
re.findall(nothing, txt2) ➞ []

bool(re.match(anything, txt1)) ➞ True
bool(re.match(anything, txt2)) ➞ True
re.findall(anything, txt1) ➞ [""]
re.findall(anything, txt2) ➞ ["This is not an empty string."]

bool(re.match(something, txt1)) ➞ False
bool(re.match(something, txt2)) ➞ True
re.findall(something, txt1) ➞ []
re.findall(something, txt2) ➞ ["This is not an empty string."]

Notas

  • No necesitas escribir una función, solo el patrón.
  • No elimines import re del código.
  • Encuentra más información sobre RegEx en Recursos.
  • Puedes encontrar todos los desafíos de esta serie en mi colección RegEx básico.