https://github.com/nijikokun/string-has
Check if a string contains a value or many values with case & locale support.
https://github.com/nijikokun/string-has
contains matching node-module string string-matching substrings
Last synced: 3 months ago
JSON representation
Check if a string contains a value or many values with case & locale support.
- Host: GitHub
- URL: https://github.com/nijikokun/string-has
- Owner: nijikokun
- License: mit
- Created: 2020-01-14T09:00:51.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-14T09:04:21.000Z (over 5 years ago)
- Last Synced: 2025-02-19T22:17:39.232Z (4 months ago)
- Topics: contains, matching, node-module, string, string-matching, substrings
- Language: JavaScript
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# string-has [](https://github.com/nijikokun/string-has/actions)
> Check whether string contains another string, or one of many strings. Supports locale and case-sensitive / case-insensitive matching.
## Install
```
$ npm install string-has
```## Usage
```js
const has = require('string-has');has('unicorns', 'corn');
//=> truehas('unicorns', ['uni', 'corn']);
//=> true
```## API
### has(input, substring, options?)
#### input
Type: `string`
String to be checked against
#### substring
Type: `string` or `array[string]`
Single substring or array of substrings for `input` to be tested against
#### options
Type: `object`
##### caseSensitive
Type: `boolean`
Default: `true`Should matching be case sensitive, or not.
##### locale
Type: `string`
Default: `en-US`Locale to use when converting `input` and `substring` to lowercase for case in-sensitive matching.