What is RegExp
What is RegExp
2021-09-22 / Dimas Lanjaka

What Is Regular Expression ?

Regular Expression (RegExp) a sequence of symbols and characters expressing a string or pattern to be searched for within a longer piece of text. Read More

What can a regular expression be used for ?

A regular expression can be a single character, or a more complicated pattern. Regular expressions can be used to perform all types of text search and text replace operations. /w3schools/i is a regular expression.

Which is the best example of a regex ?

  • Anchors — ^ and $

    RegExp Explanations
    ^Hello matches any string that starts with Hello -> Try it!
    world$ matches a string that ends with world
    ^Hello world$ exact string match (starts and ends with Hello world)
    Hello matches any string that has the text Hello in it
  • Quantifiers — * + ? and {}

    RegExp Explanations
    abc* matches a string that has ab followed by zero or more c -> Try it!
    abc+ matches a string that has ab followed by one or more
    abc? matches a string that has ab followed by zero or one
    abc{2} matches a string that has ab followed by 2
    abc{2,} matches a string that has ab followed by 2 or more
    abc{2,5} matches a string that has ab followed by 2 up to 5
    ca(bc)* matches a string that has a followed by zero or more copies of the sequence
    bca(bc){2,5} matches a string that has a followed by 2 up to 5 copies of the sequence bc
  • OR operator — | or []

    RegExp Explanations
    a(b|c) matches a string that has a followed by b or c (and captures b or c) -> Try it!
    a[bc] same as previous, but without capturing b or c
  • Character classes — \d \w \s and .

    RegExp Explanations
PermaLink: https://www.webmanajemen.com/RegExp/RegExp.html
Google Rich Snippets Schema Markup Validator