# string-plus

> string字符串增强类

Latest version **1.4.3** (published 2017-04-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install string-plus
pnpm add string-plus
yarn add string-plus
bun add string-plus
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.3 |
| Published | 2017-04-13 |
| First published | 2017-04-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | jiabing |
| Maintainers | jiabing |
| Keywords | string, string-util, char |

## Links

- npm: https://www.npmjs.com/package/string-plus
- Repository: https://github.com/w3c-king/string-plus
- Homepage: https://github.com/w3c-king/string-plus#readme
- Issues: https://github.com/w3c-king/string-plus/issues
- npm.io page: https://npm.io/package/string-plus

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 1.4.3 (latest) — 2017-04-13
- 1.4.2 — 2017-04-11
- 1.4.1 — 2017-04-11
- 1.3.2 — 2017-04-11
- 1.3.1 — 2017-04-11
- 1.3.0 — 2017-04-11
- 1.2.0 — 2017-04-11
- 1.1.0 — 2017-04-11
- 1.0.0 — 2017-04-11

## README

# 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();
```

>联系作者:<br>
	email:admin@w3c.top

---
_Source: https://npm.io/package/string-plus · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
