Read about javascript regular expression tutorial, The latest news, videos, and discussion topics about javascript regular expression tutorial from alibabacloud.com
This article was originally posted in my personal blog: http://jerryzou.com/posts/jreparser/
Yesterday, while watching the 30-minute introductory tour of regular expressions, I saw that the blogger himself implemented a C# regular tester that looked very handy. But I don't really like to mess around, so I'm wondering if I can implement a javascript
JavaScript Regular expression Knowledge collation 1. Regular Expression Mind Mapping2. Regular Expressions Common Example 2.1 remove all tags, leaving only innertextvar html = "; var text = Html.replace (/); alert (text)2.2 Remove
This article introduces common usage of JS regular expressions, involving knowledge about the usage of js regular expressions. if you are interested, learn it together and get on the right track, to learn about the usage of js regular expressions, please refer to this tutorial.
Definition and use
var patt1 = new RegE
);
}
Then there is a problem. You can try it and I don't want to post my HTML and CSS. The problem is that the elements you want to query use contains to test whether the specified class selector is false, whether or not the element is contained. Why? It was planted here last night.Debug
I put my goal on a regular expression. I was wondering if my regular
Detailed description of the replace method in the javascript Regular Expression
The syntax of the replace method is stringObj. replace (rgExp, replaceText) Where stringObj is a string, reExp can be a regular expression object (RegExp) or a string (string), and replaceText is
Regular Expression Manual:Http://tool.oschina.net/uploads/apidocs/jquery/regexp.htmlRegular expression Test address:http://tool.chinaz.com/regex/Let's give an example: E-mail[Email protected]1.username (example)([a-z0-9_\.-]+)[Email protected]@3. Company Name (qq.com)([\da-z\.-]+) \. ([A-z\.] {2,6})4.^ Match start position!5.$ Match End Position!6.[A-ZA-Z] Repres
if you are free today, you can write a calendar. on the Internet, you can see the Code formatted with a javascript date, A little dizzy after reading it. Code:
/**
The above code shows Regexp. $1. I checked it to find out:
$1... $9 is an attribute of Regexp, $1... $9: indicates the matching result of group N, which is useful when multiple groups in the regular e
JavaScript RegExp ObjectsOne. RegExp ObjectA regular expression is an object that describes a character pattern.Regular expressions are used to match string patterns and retrieve replacements, and are powerful tools for performing pattern matching on strings.1. Syntax1 var patt=New RegExp (pattern,modifiers); // Mode 1 var patt=/pattern/modifiers; //
About reverse reference
Copy codeThe Code is as follows: // test the Function
Function matchReg (reg, str ){
Var result = str. match (reg );
If (result ){
Console. dir (result );
} Else {
Console. log ('match failed ');
}
}
Var reg =/([A-Za-z] {0, 6}) \ 1 /;Var str = 'andrewandrew ';// Pass the testMatchReg (reg, str );
// Pass (? : Pattern), does not record the content matched by the sub-expression (in this example, Andrew)// Therefore, the referenc
About reverse referenceCopy codeThe Code is as follows:// Test the FunctionFunction matchReg (reg, str ){Var result = str. match (reg );If (result ){Console. dir (result );} Else {Console. log ('match failed ');}}Var reg =/([A-Za-z] {0, 6}) \ 1 /;Var str = 'andrewandrew ';// Pass the testMatchReg (reg, str );// Pass (? : Pattern), does not record the content matched by the sub-expression (in this example, Andrew)// Therefore, the reference to the matc
collection of atomsMatch any character except line break. Any character other than a line break\d matches any decimal number, i.e. [0-9]\d matches any non-decimal number, i.e. [^0-9]\s matches an invisible atom, i.e. [\f\n\r\t\v]\s matches a visible atom, i.e. [^\f\n\r\t\v]\w matches any number, letter, or underscore, i.e. [0-9a-za-z]W: matches any word character that includes an underscore. Similar but not equivalent to "[a-za-z0-9_]", where the "word" character uses the Unicode character set.
This article mainly introduces the UTF-8 regular expression how to match Chinese characters, a small partner can refer to determine whether the input content contains illegal characters, please refer to the following code
$ Str = "programming"; // if (! Preg_match ("/^ [\ x {4e00}-\ x {9fa5} A-Za-z0-9 _] + $/u", $ str )) // UTF-8 Chinese characters, letters, numbers, underscores,
I: Indicates case-insensitive when matchingSTR = "JavaScript is different from Java";reg =/java\w*/i;Arr_m = Str.match (reg);//arr_m = ["JavaScript"]G: Indicates a global match is performedSTR = "JavaScript is different from Java";reg =/java\w*/ig;Arr_m = Str.match (reg);//arr_m = ["JavaScript"]M: Indicates that matchi
Recently in reading Requirejs 2.1.15 source code, the source code at the beginning of the definition of a series of variables, there are 4 regular expressions:var commentregexp =/(\/\* ([\s\s]*?) \*\/| ([^:]|^) \/\/(. *) $)/mg, cjsrequireregexp =/[^.] \s*require\s*\ (\s*["'] ([^ '" \s]+) ["']\s*\]/g, jssuffixregexp =/\.js$/, currdirregexp =/^\.\//;Commentregexp is used to match the comments in
Use the exec () method in the Regular Expression of JavaScript
This article describes how to use the exec () method in the Regular Expression of JavaScript. It is the basic knowledge of getting started with
JavaScript regular expression characters include two categories:1, ordinary characters .2, escape character .Normal charactersUppercase and lowercase letters, numbers, and any other symbols.Escape character
Escape character
Meaning
\f
Page break
\ n
Line break
\ r
Carriage return characte
In JavaScript, the regular expression consists of two parts: the matching pattern text of the regular expression, and the modifier that matches the pattern text;Modifier:
Modifier
Description
I
Ignore case
G
Perfor
Paste (alias name): Javascript Regular Expression test webpageHow do you test regular expressions? Write the Code directly in a large segment, wait for the program to run there, and then use alert to display the result? Or is it possible to temporarily write a page and discard it after testing?
You can try this page.
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.