Have you ever found yourself feeling bewildered, trying to extract some valuable information from a string of characters? I should admit that it is similar to “finding a needle in a haystack”, unless you know regex!
Say that you want to extract the phone number of your company customers from a database log.txt that looks like this:

  1. Ema Dough (+1-202-555-0189) - 915 Ridge Street Corpus, TX 78418
  2. Tom Hitt (+33-93-751-3845) - 9190 Berkshire Ave. Wayne, NJ 07470
  3. Maya Raine (+49-30-833-931-313) - 18 SW. Sage Ave. Ride, CA 95993
    It will be a lot of work to iterate through all of the sentences and locate the numbers between the brackets. This is true indeed, until the arrival of our savior regular expressions (regex)!

#regular-expressions #programming #regex #python #data-science

RegEx Cheat Sheet - Python
1.40 GEEK