Regular Expressions (regex)

Learning outcomes:

  • Be able to identify when Regular Expressions are appropriate to use
  • Able to use Regular Expressions where appropriate
  • Able to understand and parse some Regular Expressions others have written

Would you like to download my PowerPoint to follow along?

  • What are Regular Expressions?
    • Text string used for searching, matching or even managing your information in text
    • Similar to wildcards (like * or ?) but way more powerful
  • What are Regular Expressions used for?
    • Can be used in languages like Perl, PHP, Java or even Python (with the appropriate module)
    • Useful to use for both less lines of code, less debug time and to be more efficient
  • Downside, if the person reading your code doesn't know Regex, it won't be more clear. But if they do! Much easier to use, can take lots (20) lines of code and condense it into a single line for pattern matching or string validation (such as input validation, text searching etc.)
  • Some examples of tools that use Regular Expressions
    • Sed
    • Awk
    • Grep
    • VIM
    • Emacs

Suggested Activities and Resources:

Would you like to see some more classes? Click here