What kind of regular expression will I bring to you this time? can display highlight. How can I use regular expression to display highlight? What are the precautions for regular expression display highlight? The following is a practical case, let’s take a look.
When programmers write code, they must deal withstring and "query". There is something called a regular expression at the intersection of the two. If you use this guy well, you can improve your programming efficiency. If you don't use it well... you can learn it first.
Regarding the use of regular expressions, here is a simple example:var m = location.href.match(/(\w+:)\/{0,3}([^\/]+)(?:(\/[^\?#]*))?(?:(\?[^#]+|.+))?(?:(#.*))?/); var res = { protocol: m[1], host: m[2], path: m[3], search: m[4], hash: m[5] }; console.log(res);
1. Small DEMO example of regular application
/*** @author barret lee* @date 2013-10-06* @email barret.china@gmail.com*/ //outer varvar a = "this id outer string"; //closurefunction b() { //inner var var a = "this is inner string"; var g = a.replace(/this is inner string/g, function() { return new Function("/*clousure*/this.a")(); }); /** * @description closure - regExp test * @author barret lee */ function c() { return { a: a, g: g } } return c;} var s = b()(); //s.a, s.g
/*** @author barret lee* @date 2013-10-06* @email barret.china@gmail.com*/ //outer varvar a = "this id outer string"; //closurefunction b() { //inner var var a = "this is inner string"; var g = a.replace(/this is inner string/g, function() { return new Function("/*clousure*/this.a")(); }); /** * @description closure - regExp test * @author barret lee */ function c() { return { a: a, g: g } } return c;} var s = b()(); //s.a, s.g
How to use jquery's ajax to asynchronously submit form data
How to implement springmvc to receive the array submitted by jquery Then extract the data
Detailed explanation of vue.js syntax and common instructions
The above is the detailed content of What kind of regular expression can display highlight?. For more information, please follow other related articles on the PHP Chinese website!