FrontendDeveloper.in

JavaScript question detail

What are regular expression patterns

Regular Expressions provide a group of patterns in order to match characters. Basically they are categorized into 3 types,

  1. Brackets: These are used to find a range of characters. For example, below are some use cases,
  2. [abc]: Used to find any of the characters between the brackets(a,b,c)
  3. [0-9]: Used to find any of the digits between the brackets
  4. (a|b): Used to find any of the alternatives separated with |
  5. Metacharacters: These are characters with a special meaning. For example, below are some use cases,
  6. \d: Used to find a digit
  7. \s: Used to find a whitespace character
  8. \b: Used to find a match at the beginning or ending of a word
  9. Quantifiers: These are useful to define quantities. For example, below are some use cases,
  10. n+: Used to find matches for any string that contains at least one n
  11. n*: Used to find matches for any string that contains zero or more occurrences of n
  12. n?: Used to find matches for any string that contains zero or one occurrences of n
Back to all JavaScript questions
Get LinkedIn Premium at Rs 399