JavaScript Learning Notes-Reference type REGEXP

Source: Internet
Author: User

Four REGEXP

Format:

var expression =/pattern/flags;

1.flags is a sign. Are G, I, M respectively.

G: Represents the global pattern. That is, the pattern will match all the strings, not stop immediately when the first match is found.

I: indicates case insensitive.

M: represents multiline mode, which will continue to look for the next line when it reaches the end of a line of text.

Properties of 2.REGEXP Instances

Global: Whether the G mark is set;

IgnoreCase: Whether the I flag is set;

LastIndex: Indicates the character position at which to start searching for the next occurrence, starting from 0;

Multiline: Whether the M flag is set;

Source: A string representation of a pattern

var pattern =/\[bc\]at/i;alert (Pattern1.global);   Falsealert (pattern1.ignorecase);   True    alert ();   Falsealert ();   0alert ();   "\[bc\]at"

3.RegExp instance method

EXEC () receives 1 parameters. A string that applies a pattern to the drug.

var text = "Father and mother I love You";    var pattern =/I love you/gi; var matched = pattern.exec (text);

JavaScript Learning Notes-Reference type REGEXP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.