What is "regex"

Regular Expressions are a powerful form of declarative programming languages, mainly to find matching of a pattern in a string.

Different tools and programming languages may use different dialects (called Flavors) which are variations in the way you work with Regex, including elements of syntax, resources and even the behavior of certain structures - the same regex can work in different ways, depending on the language and expression used (or it may still work on one but not the other, by using resources that only one of them supports).

Therefore, when you ask a question, include the language tag or tool you are using. Otherwise you may receive answers that do not work in your case. Don’t forget to be very specific about what you need (what - and how many - characters you want and which you don’t want regex to find, for example), as these details can completely change the solution.

Regular Expressions are used for two purposes: input validation and data extraction.

Sites to test Regex

  • regex101 (in PCRE-compatible, Javascript, Python, Go, generates explanation of the pattern)
  • Regexplanet (supports a wide variety of Flavors)
  • Regexpal (Ecmascript launder, same as the Javascript)
  • Regexhero (.NET launder)
  • Regexr (gskinner.com - Ecmascript launder, same as Adobe Flash)
  • reFiddle (javascript)
  • Blush (Ruby launder)
  • myregexp.com
  • regexper.com (generates graphic representation, Ecmascript launder)
  • debuggex (generates graphical representation and shows the pattern process, in Javascript, Python and PCRE-compatible)

Regex Learn/Train Game

  • Regex Cross-word (game/tutorial that works like crosswords in which columns and rows contain regular expressions and their intersections need to be filled with the single character that is "combined" by both expressions).

Books

Online Learning Resources