|
|
@@ -192,6 +192,26 @@ export function getParenthesesStr(text) {
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 是否以某一字符串开头
|
|
|
+ * @param s
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
+String.prototype.startWith = function (s) {
|
|
|
+ if (s == null || s == "" || this.length == 0 || s.length > this.length)
|
|
|
+ return false;
|
|
|
+ if (this.substr(0, s.length) == s)
|
|
|
+ return true;
|
|
|
+ else
|
|
|
+ return false;
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 是否以某一字符串结尾
|
|
|
+ * @param s
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
String.prototype.endWith = function (s) {
|
|
|
if (s == null || s == "" || this.length == 0 || s.length > this.length)
|
|
|
return false;
|
|
|
@@ -202,7 +222,10 @@ String.prototype.endWith = function (s) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+/**
|
|
|
+ * 是否存在于参数字符串列表中
|
|
|
+ * @returns {boolean}
|
|
|
+ */
|
|
|
String.prototype.isStrEquals = function () {
|
|
|
let args = arguments
|
|
|
if (isObjNull(args) || args.length == 0) {
|
|
|
@@ -221,6 +244,20 @@ String.prototype.isStrEquals = function () {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 字符串全局替换
|
|
|
+ * @param reg
|
|
|
+ * @param s
|
|
|
+ * @returns {string}
|
|
|
+ */
|
|
|
+String.prototype.replaceAll = function (reg, s) {
|
|
|
+ if (isObjEmpty(this)) {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ return this.replace(new RegExp(reg, 'gm'), s)
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
//yyyy-MM-dd hh:mm:ss
|
|
|
Date.prototype.format = function (fmt) {
|
|
|
let o = {
|
|
|
@@ -241,25 +278,6 @@ Date.prototype.format = function (fmt) {
|
|
|
}
|
|
|
|
|
|
|
|
|
-String.prototype.startWith = function (s) {
|
|
|
- if (s == null || s == "" || this.length == 0 || s.length > this.length)
|
|
|
- return false;
|
|
|
- if (this.substr(0, s.length) == s)
|
|
|
- return true;
|
|
|
- else
|
|
|
- return false;
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-String.prototype.replaceAll = function (reg, s) {
|
|
|
- if (isObjEmpty(this)) {
|
|
|
- return ''
|
|
|
- }
|
|
|
- return this.replace(new RegExp(reg, 'gm'), s)
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* Map转json
|
|
|
* @param m
|