1.4.3 • Published 7 years ago

string-plus v1.4.3

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

string-plus

JS字符串增强类

#快速入门

引入模块

	let StringPlus = require("string-plus");

创建对象

	let str = new StringPlus(val);
	let str = new StringPlus("Hello");

添加字符

	str.append(val);
	str.append("World");  // HelloWorld

判断是否为空

	str.isNullOrEmpty(); // false

判断字符串是否为Null或者为空字符串或者全是空格。

	str.isNullOrWhiteSpace(); // false

判断字符串是否包含指定的内容

	str.isContains(val);
	str.isContains("Hello"); // true

返回反转后副本

	str.reverse();

去除字符串左边的空格

	str.ltrim();

去除字符串右边的空格

	str.rtrim();

去除字符串两边的空格

	str.trim();

判断字符串是否以指定内容开头

	str.startsWith(val);
	str.startsWith("He"); // true

判断字符串是否以指定内容结尾

	str.endsWith();
	str = new StringPlus("HelloWorld");
	str.endsWith("orld"); // true

判断字符串是否是长日期

	date.isLongDate();
	new StringPlus("2017-4-11 15:27:01").isLongDate(); // true

判断字符串是否是短日期

	date.isShortDate();
	new StringPlus("2017-4-11").isShortDate(); // true

判断字符串是否是日期

	date.isDate();
	new StringPlus("2017-4-11 15:27:01").isDate(); // true

判断字符串是否是电话

	str.isMobile();
	new StringPlus("13416666666").isMobile(); // true

判断字符串是否是电子邮箱

	str.isEmail();
	new StringPlus("admin@w3c.top").isEmail(); // true

判断字符串是否存在汉字

	str.isExistChinese(); // false

判断字符串是否全是汉字

	str.isChinese(); // false

判断字符串是否全是字母

	str.isAbc(); // true

将字符串日期转换成日期类型

	str.toDate();

将字符串转换成对应的bool值

	str.toBool();

将字符串转换成对应的int

	str.toInt();

将字符串转换成对应的Double

	str.toDouble();

将字符串转换成对应的json对象

	str.toJson();

将字符串转成字符数组。

	str.toCharArray();

保留数字

	str.getNum();

保留中文

	str.getCN();

得到字符串表现形式

	str.toString();

联系作者: email:admin@w3c.top

1.4.3

7 years ago

1.4.2

7 years ago

1.4.1

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.0

7 years ago