Copyright © 2017, edureka and/or its affiliates. All rights reserved.
JAVASCRIPT REGEX
MODIFIERS
BRACKETS
www.edureka.co
METACHARACTERS
QUANTIFIERS
OBJECT PROPERTIES
OBJECT METHODS
www.edureka.co
A Regular Expression is a sequence of characters that constructs a search pattern. When you search for data in a text,
you can use this search pattern to describe what you are looking for.
What are Regular Expressions?
www.edureka.co
www.edureka.co
g It performs a global match
i It performs case-insensitive matching
m It performs multiline matching
www.edureka.co
www.edureka.co
[abc] Finds any character between the brackets
[^abc] Finds any character NOT between the brackets
[0-9] Finds any digit between the brackets
[^0-9] Finds any non-digit NOT between the brackets
www.edureka.co
www.edureka.co
w It looks for a word character
W It finds a non-word character
d It finds a digit
D It finds a non-digit Character
s It finds a whitespace character
S It finds a non-whitespace character
b It finds a match at the beginning/end of a word
B It looks for a match, but not at the beginning/end of a word
f It finds a form feed character
r It finds a carriage return character
v It finds a vertical tab character
t It finds a tab character
www.edureka.co
www.edureka.co
n+ It matches any string that contains at least one n
n* It matches any string that contains zero or more occurrences of n
n? It matches any string that contains zero or one occurrence of n
n{X} It matches any string that contains a sequence of X n’s
n{X,Y} It matches any string that contains a sequence of X to Y n’s
n{X,} It matches any string that contains a sequence of at least X n’s
n$ It matches any string with n at the end of it
www.edureka.co
www.edureka.co
Constructor Returns the function that creates the RegExp object’s prototype
global Checks whether the “g” modifier is set
ignoreCase Checks whether the “i” modifier is set
lastIndex Specifies the index at which to start the next match
multiline Checks whether the “m” modifier is set
www.edureka.co
www.edureka.co
Compile() It compiles a regular expression
exec() It tests for a match in a string and returns the first match
test() It tests for a match in a string and returns true or false
toString() It returns the string value of the regular expression
www.edureka.co
Copyright © 2017, edureka and/or its affiliates. All rights reserved.
www.edureka.co
www.edureka.co

What is JavaScript Regex | Regular Expressions in JavaScript | Edureka

  • 1.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved.
  • 2.
  • 3.
  • 4.
    A Regular Expressionis a sequence of characters that constructs a search pattern. When you search for data in a text, you can use this search pattern to describe what you are looking for. What are Regular Expressions? www.edureka.co
  • 5.
  • 6.
    g It performsa global match i It performs case-insensitive matching m It performs multiline matching www.edureka.co
  • 7.
  • 8.
    [abc] Finds anycharacter between the brackets [^abc] Finds any character NOT between the brackets [0-9] Finds any digit between the brackets [^0-9] Finds any non-digit NOT between the brackets www.edureka.co
  • 9.
  • 10.
    w It looksfor a word character W It finds a non-word character d It finds a digit D It finds a non-digit Character s It finds a whitespace character S It finds a non-whitespace character b It finds a match at the beginning/end of a word B It looks for a match, but not at the beginning/end of a word f It finds a form feed character r It finds a carriage return character v It finds a vertical tab character t It finds a tab character www.edureka.co
  • 11.
  • 12.
    n+ It matchesany string that contains at least one n n* It matches any string that contains zero or more occurrences of n n? It matches any string that contains zero or one occurrence of n n{X} It matches any string that contains a sequence of X n’s n{X,Y} It matches any string that contains a sequence of X to Y n’s n{X,} It matches any string that contains a sequence of at least X n’s n$ It matches any string with n at the end of it www.edureka.co
  • 13.
  • 14.
    Constructor Returns thefunction that creates the RegExp object’s prototype global Checks whether the “g” modifier is set ignoreCase Checks whether the “i” modifier is set lastIndex Specifies the index at which to start the next match multiline Checks whether the “m” modifier is set www.edureka.co
  • 15.
  • 16.
    Compile() It compilesa regular expression exec() It tests for a match in a string and returns the first match test() It tests for a match in a string and returns true or false toString() It returns the string value of the regular expression www.edureka.co
  • 17.
    Copyright © 2017,edureka and/or its affiliates. All rights reserved. www.edureka.co
  • 18.