Read about javascript regular expression tutorial, The latest news, videos, and discussion topics about javascript regular expression tutorial from alibabacloud.com
Text: JavaScript Regular expression Quick judgment skillHere is a bit of JS's experience, not the most complete rule summary, more emphasis on the actual use of the rapid judgment, beginner contact is often followed by a bunch of star brackets to stun, with a number of quick-judging techniques can be grasped from the overall and not flustered. The core of JS
Example of the replace method of a JavaScript string object (for string replacement or regular expression replacement), javascriptreplace
JavaScript replace Method
The replace method is used to replace some strings with other strings, or replace strings that match the regular
Php date format validity regular expression verification code. Php date format legality regular expression verification code this php regular expression date tutorial provides three met
Many students who learn JS development may have a dismissive attitude to the regular expression, that the use of the time to check the line. When I used to learn other languages, such as Java and C #, I had the idea that I didn't have to forget it anyway.However, in JS development, you will use regular expressions more frequently, whether you are developing your
If you've ever used Perl or any other built-in regular expression-supported language, you know how simple it is to handle text and matching patterns with regular expressions. If you are unfamiliar with the term, then "regular expression" (
is returned, and the static property in the RegExp object is updated to reflect the matching situation. Element 0 in the returned array contains the complete match result, and the element 1~n in turn is the result of each sub-match defined in the expression pattern.
The array returned by the Exec method has 3 properties, namely input, index, and lastindex.
The input property is the entire string being searched for.
The Index property refers to
There are two ways that JavaScript defines regular expressions.
1.REGEXP Constructors
var pattern = new RegExp ("[Bc]at", "I");
It receives two parameters: one is the string pattern to match, and the other is the optional flag string.
2. Literal volume
var pattern =/[bc]at/i;
The matching pattern for regular expressions supports three kinds of flag strings:
JavaScript Regular Expression Test Web page
How do you normally test regular expressions? Write directly in a large section of code, then wait for the program to run there, and then display the results with alert? Or do you write a page temporarily and throw it away after the test is done?
You can try my this page, a
Today, I am browsing the frequently used topology (. NET does not exist,. Net please refer to msdn ).
The following documents are provided:
Jquery: Jquery 1.4.1 references. CHM
Javascript: Javascript user manual. CHM
Html: Html4 reference manual. CHM
HTML5 reference manual. CHM
CSS: CSS 2.0 Chinese manual. CHM
CSS 3.3 Chinese manual. CHM
PHP: Php5.3 reference manual. CHM
MySQL: Mysql5.1 re
(match3 );You can also use Regexp to create a matching expression, which is conducive to passing variables to the matching expression "//"A = 'a + ';Alert (New regexp(acmd.exe C ('123aaaabcdef '));The exec method can also be used by a matching expression like.Alert (/[0-9] +/cmd.exe C ('12345abcdef '))Javascript suppo
is the above jqueryhandle.jsp code, a simple can not be simpler JSP code, the need to get the number1 and number2 two values, and then convert them to Integer, then add, and add their results after the result output.However, this code is supposed to prevent malicious users from directly accessing this page error, so should be added to throw an exception structure, protect this page3, jqueryajax.jsp The entire page polls the Jqueryajax () function every 0.5 seconds, jqueryajax (), and details ca
This article will continue to update-------------------------------------------------------------------------------------------------------------Basic syntaxAbout the grammar part is not wordy, the world can find relevant knowledgeFor more information see: W3school reference manual JavaScript RegExp ObjectOf course, you can also refer to the following blog in the garden of other people's blog, I do not repeat the wheel:JS
have both long and short (Perl style) names, and these two names point to the same value. (JavaScript simulates Regular Expressions in Perl) attributes of a regular expression object
Attribute
Description
$1... $9
If it exists, it is a matched substring.
$ _
See Input
② Directly count characters:
As mentioned in the previous article, all the letters and numbers in the regular expression are directly matched with their own numbers. The regular expression syntax of JavaScript also supports certain non-letter characters through escape sequen
‘,patt=/e/g;function fun(){ console.log(patt.lastIndex); console.log(patt.test(str));}fun(); //0,truefun(); //2,falsefun(); //0,truefun(); //2,false//解决方案:1、不用g2、在第二次使用前设置patt.lastIndex=0;即可。Methods for string objects that support regular expressions
Method
Description
Match
Retrieves the value specified in the string. Finds one or more matching results, and outputs an array. There is no match
. Practice: Use a reverse reference to write an expression that matches a person's name, assuming that the first name of the person is the same as the last name.Answer: ([a-z][a-za-z]*) s1Comments back to catalog [1] This article is translated from the Regular Expressions of Java Tutorial, the title is the translator's own. --Translator's note
[2] Unix tool, use
Below we give a PHP regular expression matching string in the specified tag implementation program code, there is a need to learn friends can refer to this tutorial.
In PHP applications, regular expressions are mainly used to:
• Regular match: matches the corresponding conte
the previous item once or multiple times
*
Match the previous item 0 or multiple times
Duplicate characters * and? Note that these characters may match the first 0 instances, so they allow no match. For example, the regular expression/A */actually matches the string "BBBB" because the string contains 0.
⑤ Non-Greedy repetition
The repeated characters listed in the above table can match as
Regular Expressions are often used in Javascript, such as verifying whether input formats such as email addresses and birthdays are valid. The following describes the regular expression usage in JS:
I. metacharacters
. Match any character, except for line breaks
\ D Number
\ W digits or letters
\ S space, including spa
Php regular expressions match Chinese characters. The article tells you how to use php regular expressions to match Chinese characters. The following describes how to use preg_matchmb_eregi to verify Chinese characters and solve problems in the regular expression process. The article tells you how to use php
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.