String.prototype.len=function () {return This.replace ([^x00-xff]/g, "AA"). Length;}
(2) Application: JavasCript does not have a trim function like VBScript, we can use this expression to implement
String.prototype.trim = function ()
{
Return This.replace (/(^s*) | ( s
captured in the group ),* The end of the last string is zero or multiple spaces.* Use the String object's replace () method and reverse reference,* You can customize your trim () method:*/String. prototype. trim = function (){Var reExt =/^ \ s *(.*?) \ S + $ /;/** $1 indicates the characters in brackets in the left expression, that is, the first child match,* Similarly, $2 indicates the second child match.
If you're still a beginner, and you've read all of these tips and each of these tips is to use them later, you'll write more concise and efficient JavaScript programs.Indeed, JavaScript gurus have used these techniques to write a lot of powerful, efficient JavaScript programs. But you can do that.Strong | | An expressionYou may have seen them in
The definition in JavaScript1. A regular expression is defined by the RegExp constructor function. The first parameter is a regular expression that is passed in as a string, and the second parameter is a modifier that also passes in as a string.例:var caps = new RegExp("[A-Z]", "g");2, directly define a regular expression
= Option.emojiarray,
this.textareaid = Option.textareaid,
this.loadid = Option.loadid,
this.sendid = Option.sendid,
This.emojicontainer = Option.emojicontainer,
this.emojitranslatecls = option.emojitranslatecls;
}
Each time an instance is generated, the properties above are regenerated once, which consumes a bit more memory for a fixed method. This is neither environmental protection nor efficiency. So the invariant properties and methods can be defined directly on the prototype object. At
function tag, we can intercept the content display, fn:substring ();(3) In addition, we often use the format of the data to display the alias FMT label, the implementation of formatting display date, data, currency.Finally, the eval () in JavaScript, first it is a function that computes a string and executes the JavaScript
Regular expression pattern matching JavascriptSummary: Collects some commonly used regular expressions.Regular expressions are used for string processing, form validation, and so on, practical and efficient, but often not too sure to use, so it is always necessary to search the Internet. I've collected some commonly used expressions here for the purposes of my memo. This post will be updated at any time. Matching regular expressions for Chinese charac
validation*/function Checkseccode (seccode) {if (Seccode.length!=6) {Alert ("The length of the security code should be 6 bits");return false;}if (!isnumber (Seccode)) {Alert ("Security code can only contain numbers");return false;}return true;}/*Function:ctrim (Sinputstring,itype)Description: Function of string de-whitespaceparameters:itype:1= Remove the space to the left of the string2= Remove the space t
Regular expression parsing in JavaScriptThe regular expression (regular expression) object contains a regular expression pattern. It has attributes (properties) and methods (methods) that match or replace a particular character (or character set) in a string in a regular expression
Regular Expression parsing in JavaScript
The regular expression object contains a regular expression pattern ). It has the properties and methods used to match or replace a specific character (or character set combination) in a string (string) in the regular expression mode
function expressions and Function declarations
In ECMAScript, the two most commonly used methods of creating functions are function expressions and function declarations, and the difference between the two is a bit faint, because the ECMA specification is only a bit clear: the fun
, because the function Declaration requires a name.
You may think again, if I input a parameter in braces, will it be parsed into an expression?
function sayHello(){alert("hello");}(1);
Indeed, the error is gone. However, the above statement is equivalent to the following statement.
function sayHello(){alert("hello")
Document directory
C {n}
C {m, n}
C {n ,}
*, + ,?
Greedy and non-greedy
Matching results of sub-regular expressions are not recorded
Forward pre-Query
?!
Global match, modifier g
Case-insensitive, modifier I
The end of the first line, modifier m
Exec method Return Value
Update the regular expression using the exec Method
Match Method
Replace Method
Search Method and split method
Method 1:
VaR Reg =/pattern /;
Method 2:
VaR Reg = ne
standard is not fully implemented.
1.1 Direct Measure characters
All letters and numbers in a regular expression are matched by literal meaning. JavaScript Regular expression syntax also supports non-alphanumeric character matching, which need to be escaped with a backslash (\) as a prefix. For example, escape characters \ n are used to match line breaks. Thes
An overview of Android expressive function processing scheme
1. Principle and Realization idea
2. Facial Image Display
3. Facial Expression Panel
4. Insert and delete the expression of the input box
5. Facial expression Add script
Android in the expression
, Instead of stopping m after finding the first one: multiple-line matching pattern, ^ matches the beginning of a line and the beginning of a string, $ matches the end of a row and the end of a string method search (): its argument is a regular expression that returns the starting position of the first substring to match. Returns-1 if there is no matching substring. If the search () parameter is not a regular expr
://([w-]+.) +[w-]+ (/[w-/?%=]*)?
(1) Application: Computes the length of the string (a double-byte character length meter 2,ascii character count 1)String.prototype.len=function () {return This.replace ([^x00-xff]/g, "AA"). Length;}
(2) Application: JavaScript does not have a trim function like VBScript, we can use this exp
global retrieval, finds all matching substrings in the string, returns null if no matching substring is found, and returns an array if one or more matching substrings are found. The array element holds all matching substrings in the string, and there is no index or input property.var reg3=/\d (\w) \d/; var reg4=/\d (\w) \d/g; var ts= ' $1a2b3c4d5e '; var ret=ts.match (REG3); Console.log (ret);//[' 1a2 ', ' a ', index:1, input: ' $1a2b3c4d5e '] console.log (ret.index + ' \ t ' +reg3.lastindex);/
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.