Regex Tutorial

Learn regular expressions from scratch

1. Regex Basics

A regular expression (regex) is a sequence of characters that defines a search pattern. Regular expressions are used for:

  • String matching and searching
  • Input validation
  • Text replacement
  • Data extraction

Example:

/hello/ matches the string "hello"

The pattern is enclosed between forward slashes (/pattern/). This is the literal notation in JavaScript.