omit the argument.
return valueA new RegExp object with the specified pattern and flags. If parameter pattern is a regular expression instead of a string, the RegExp () constructor creates a new RegExp object with the same pattern and flags as the specified REGEXP.
If you do not use the new operator and REGEXP () as a function call, its behavior is the same as when called with the new operator, except t
polluted.The following part of the original source: http://www.cnblogs.com/isaboy/p/javascript_function.htmlJavascript function is ubiquitous and powerful! JavaScript functions allow JS to have some object-oriented features, such as encapsulation, inheritance, and so on, can also be used to reuse code. But there are two sides to things, JavaScript functions some
Using the explicit constructor of REGEXP, the syntax is: New REGEXP ("pattern" [, "Flags"]).
Use the implicit constructor of RegExp, in plain text format:/pattern/[flags].
The pattern section is required for the regular expression schema text to be used. In the first way, the pattern part is in the form of a JavaScript string that needs to be enclosed in double quotes or single quotes; in the second way, th
definitely not a problem, because the first argument passed in itself is a string. To create in the first way, you need to use the Eval () function, as follows
Copy Code code as follows:
var str = "ABC"; This could be a dynamic variable
var patt1 = eval ("/\\[" +str+ "\\]/"); Equivalent to var patt1 =/\[abc\]/;
Alert ("[ABC]". Match (PATT1)); return [ABC]
b, what is the difference between the above two methods of creation?
Regular expression replace () function:This function replaces the substring in the string that matches the regular expression with the specified string.The return value is a new, replaced string.This only describes the actions of regular expressions, and other substitutions can refer to the text of the replace () method of a
Example of jQuery regular expression-based form verification function, jquery Regular Expression
This document describes jQuery's form verification function based on regular expressions. We will share this with you for your reference. The details are as follows:
Appendix: Common js verification functions:
Website home
FnName (); function fnname() {...} //Normal, because ' Ascend ' function declaration, function call can be before function declaration fnname (); varfnname=function (//error, variable fnname has not saved a reference to the funct
Regular expression: a regular expression processing function. We have learned the basic syntax of regular expressions, including delimiters, atoms, metacharacters, and pattern modifiers. In fact, to work with a regular expression, you must use the basic syntax that we have learned before, including the delimiters, atom
There are two sets of regular expression libraries in PHP that are similar in functionality, but have slightly different execution efficiencies:
A set is provided by the Pcre (Perl compatible Regular Expression) library. A function named after a prefix using "preg_";
A set of (PHP default) extensions provided by POSIX (Portable operating System Interface of Unix)
point can be unavailable (that is, an integer is also acceptable, not just a pure decimal point)
But before the decimal point, 00.123 is also acceptable.
No.
4./^ [+-]? \ D + (\. \ d + )? $/
It is also better, for example, taking into account the plus and minus signs, but before the same decimal point, 00.123 is also acceptable.
If you don't want to find more, this is probably the case.
-----------
Below is a method I have tested multiple times:
var regExp = /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g;v
Methods for defining functionsThere are three main ways to define a function:
Functions declaration (Function Declaration)
function expression)
New function constructor
Among them, the function declaration an
(Re.test (str));
alert (regexp.$1);//one
Build a regular expression that verifies the validity of an e-mail address. e-mail address validity requirements (we would like to define): The user name can only contain alphanumeric and underscores, at least one digit, up to 25 digits, followed by the @, followed by the domain name, and domain names require only alphanumeric and minus signs (-), and cannot begin or end with a minus sign. Then follo
REGEXP: is shorthand for regular expressions (regular expression).
A regular expression describes the pattern object of a character. You can use regular expressions to describe what you want to retrieve.
A simple pattern can be a single character. More complex patterns include more characters and can be used for parsing, format checking, substitution, and more.
Determines whether the input is an empt
JavaScript Regular expression usage:
Copy Code code as follows:
function Checkreg (myreg,mytext)
{
if (Myreg.test (MyText)
{
Alert ("OK");
return true;
}
Else
{
return false;
}
}
Another way of writing
Copy Code code as follows:
function Checkreg (myreg,mytex
Ways to define functions There are three main ways to define a function: Functions Declaration (Function Declaration)Functional expression function Expression)New function constructor Among them,
Regular expression in PHP: a summary of regular expression processing functions (preg_match, preg_match_all, preg_replace, pr. We have learned the basic syntax of regular expressions, including delimiters, atoms, metacharacters, and pattern modifiers. In fact, to work with a regular expression, you must use the basic syntax that we have learned before, including
Convert a number to a js function of the Renminbi expression, expression js
There are many ways to convert numbers into large-sized RMB. This example describes how to use js to complete the conversion. Let's take a look at the following implementation code.
Function changeNumMoneyToChinese (money) {var cnNums = new Arr
We have already learned the basic syntax for regular expressions, including delimiters, atoms, metacharacters, and schema modifiers. In fact, the regular expression handler function must be borrowed in the case in which it is intended to work. In this section, we will introduce Perl regular expression processing functions in PHP, including segmentation, matching,
In PHP There are two sets of regular expression libraries. A set is provided by the Pcre (Perl compatible Regular Expression) library. The Pcre library implements pattern matching for regular expressions using the same syntax rules as Perl, using functions named "Preg_" as prefixes. The other is provided by the POSIX (Portable Operation System Interface) extension Library. POSIX-extended regular expressions
"Function declarations" and "function expressions" are actually the way to define functionsfunction declaration:Function name () {...}a function defined by the above method is a function declarationfunction Expression: Functions are defined by
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.