1. Use regular expressions to implement startWith and endWith effect functions
String.prototype.startWith=function(str){
var reg=new RegExp("^" str);
return reg.test(this);
}
//Test ok, directly Just use str.endWith("abc") to call
String.prototype.endWith=function(str){
var reg=new RegExp(str "$");
return reg.test( this);
}
2. JavaScript implements startWith and endWith effect functions
Latest Articles by Author
-
2025-02-24 12:36:12
-
2025-02-24 12:11:09
-
2025-02-24 12:06:10
-
2025-02-24 12:04:13
-
2025-02-24 12:03:10
-
2025-02-24 12:02:09
-
2025-02-24 12:01:10
-
2025-02-24 12:00:16
-
2025-02-24 11:59:10
-
2025-02-24 11:58:14