ECMAScript supports regular expressions through the REGEXP type. Using the following Perl -like syntax, you can create a positiveThe expressionvar expression =/pattern/flags;The patternsection can be any simple or complex regular expression that
1. Test method of regular expression
var text = "Cat, bat, Sat, fat";
var pattern =/.at/;
if (pattern.test (text)) {
alert ("The pattern is matched.");
}
2, regular ToString () method
var pattern = new RegExp ("\\[
To create the syntax for a RegExp object:
var obj=new RegExp (pattern,attributes);
The code is as follows
Copy Code
Case 1:var pattern=/a/;document.write (Pattern.exec ("Asdas"));Case 2:var obj=new RegExp ("a");document.
Regexp ^ ??????????????????????? Match the starting part of the string $ ??????????????????????? Matches the end part of the string .???????????????????????? Match any character (including carriage return and new line *????????????????????? Match
First, JavaScript Regular expression overviewRegular Expressions Overview-Regular Expressions (Regular expression): Expressions that are composed of ordinary characters and special characters that describe a particular character rule-Regular
A regular expression is an object that describes the character mode.The Regexp object and string object in Javascript define a method that uses regular expressions to execute powerful pattern matching and text retrieval and replacement functions.'***
The Regexp.$1...$9 property is used to return text that matches a subexpression in the regular expression pattern. A group that resembles the match method in C #.
A partial expression within each parenthesis in a regular expression is a
regexp types contain information: Patterns and flagsTo create a RegExp object:Method One:Literal formvar expression =/pattern/flags;Flags
G: Global mode, the pattern will be applied to all strings, rather than stopping when the first match
The RegExp object in JavaScript is an intrinsic global object that holds information about the pattern-matching of regular expressions. How to use:Regexp.propertyThe mandatory option property parameter is any of the properties of the RegExp object.
JavascriptRegExp Object
REGEXP: is a shorthand for regular expressions (regular expression).
Complete RegExp Object reference manualSee our reference Manual for JavaScript REGEXP objects, which provides all the properties and methods you
1. Array typeEach item of the ECMAScript array can hold any type of data, and the size of the array can be dynamically adjusted;(1) Creating an arrayFirst method: Array constructor var colors=new Array ();var colors1=new Array (20);var colors2=new
ECMAScript supports regular expressions through the regexp type.Grammar:var expression =/pattern/flags;The matching pattern for regular expressions supports the following 3 flags.1.G: Represents the global pattern, which means that the pattern will
One, RegExp type1. Literal methodvar expression=/pattern/flags;Where the pattern section can be any simple or complex regular expression, each regular expression can have one or more flags (flags)G: Represents the global mode, which will be applied
In mysql, like and regexp are implemented for Fuzzy queries. ------------------------ Many people know the usage of like. The most common case is select * fromawherenamelike % a %. % indicates any character, and its effect is like * in a regular
One: Define the way① literal way var pattern =/pattern/attributes② constructor mode var pattern = new RegExp ("pattern", "attributes");Attributes parameter: Can be the value of G (global: whether globally); I (ignoreCase: If case is ignored); M
Regular Expressions in JavaScript:Let's start with a brief description of regular expressions in JavaScript. The ECMAScript v3 standardizes JavaScript Regular Expressions. JavaScript 1.2 implements a subset of the regular expressions required by the
The exec () method of the JavaScript RegExp object is used to match the string, and its behavior is somewhat different from match ().For Regexpobject.exec (), W3school is described above:
The exec () method is powerful, is a common method,
REGEXP is a built-in object in JavaScript. is a regular expression.Regexp.$1 is a property of RegExp that refers to the first sub-match (in parentheses) string that matches the regular expression.And so on, regexp.$2,regexp.$3, ... Regexp.$99 can
In the previous article we introduced JavaScript regular expressions and string regexp and string (a), and this article continues to share relevant content.
Objective
I think that in the process of learning a programming language, strings, arrays,
Direct volume syntax
/pattern/attributes
To create the syntax for a RegExp object:Copy code code as follows:var obj=new regexp (pattern,attributes);
Case 1:Copy code code as follows:var pattern=/a/;document.write (Pattern.exec ("Asdas"));
Case 2:
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.