A regular expression is a logical formula for a string operation, which is a "rule string" that is used to express a filter logic for a string, using predefined specific characters and combinations of these specific characters.The given characters
Get all the addresses in the string to an array we use the Preg_match_all functionCode to copy code as follows$str = ' ";$pattern = "//];Preg_match_all ($pattern, $str, $match);p Rint_r ($match);?>ResultsArray([0] = = Array([0] = )[1] = = Array([0] =
Regular expressions
Basic syntax meta-character
Code
Description
Example
.
Match any character except for a line break
[ABC]
The character set can only represent one
What is a regular expression?A regex (regular expression) is a string containing a normal string and a special metacharacters (meta characters) or meta-sequences. Normal strings match themselves. Metacharacters and meta sequences are characters or
Regular expression syntax
A regular expression is a literal pattern consisting of ordinary characters (such as characters A through Z) and special characters (called metacharacters ). This pattern describes one or more strings to be matched when
Objective
Regular expression is cumbersome, but powerful, after the application of learning will let you in addition to improve efficiency, will give you a sense of absolute achievement. As long as the careful reading of these materials, coupled
The RegExp object provides a simple regular expression support feature.
Use of RegExp objects:
Copy Code code as follows:
Function regexptest (PATRN, STRNG)
Dim regEx, Match, matches ' Set variable.
Set regEx = New RegExp '
Copy Code code as follows:
(?:p Attern) matches pattern but does not get matching results, which means that this is a non fetch match and is not stored for later use. This is useful for combining parts of a pattern with the "or" character (|
1.
regular-expression literal characters Character matches
Alphanumeric character itself
The NUL character (\u0000)
\ t Tab (\u0009)
\ newline (\u000a)
\v Vertical tab (\U000B)
\f Form
http://regexpal.com/
The above website can be used to detect JS's regular expression syntax online
In addition to the well-known several fixed character representation position:
^: Match The beginning of the string and, in multiline searches,
The article to share the PHP regular Expression Security Tutorial Foundation, this article will continue to extend the knowledge of PHP regular expressions, see below for details.
Operation Precedence for various operators of PHP regular
Regular Expressions Learning Notes
A regular expression (regular expression) describes a pattern of string matching that can be used to check whether a string contains
There is a seed string, a matching substring is substituted, or a substring is
Characters
Meaning: For a character, it is usually indicated by literal meaning that the character followed by a special character is not interpreted.
For example:/b/matches the character ' B ', which becomes a special character by adding a
Here are some examples of regular expressions that you might encounter:
/^\[\t]*$/"^\[\t]*$" matches a blank line.
/\d{2}-\d{5}/"\d{2}-\d{5}" verifies that an ID number consists of a 2-bit character, a hyphen, and a 5-digit number.
/.*/".*" matches
Only numbers can be entered: "^[0-9]*$".Only n digits can be entered: "^\d{n}$".You can enter at least n digits: "^\d{n,}$".You can enter only the number of m~n digits:. "^\d{m,n}$"Only numbers beginning with 0 and not 0 can be entered: ^ (0|[ 1-9][0
Objective
CSS selector, is the front-end basic skills, as long as you are a front-end, this must be mastered! Today I want to revisit the CSS selector, mainly to review some of the CSS selector in the use of some common symbols, such as "+, ~, ^, $,
A method of defining regular expressions
There are two ways to define a regular expression: the constructor definition and the regular expression direct quantity definition. For example:
Copy Code code as follows:
var reg1 = new
When to use regular expressions.
In the process of program development, it is often necessary to perform the matching, searching, extracting, replacing and judging of the text content repeatedly. If the individual only use code to achieve the
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.