is-word-character

Check if a character is a word character

Usage no npm install needed!

<script type="module">
  import isWordCharacter from 'https://cdn.skypack.dev/is-word-character';
</script>

README

is-word-character

Build Coverage Downloads Size

Check if a character is a word character (\w, which equals [a-zA-Z0-9_]).

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install is-word-character

Use

import {isWordCharacter} from 'is-word-character'

isWordCharacter('a') // => true
isWordCharacter('Z') // => true
isWordCharacter('0') // => true
isWordCharacter('_') // => true
isWordCharacter(' ') // => false
isWordCharacter('💩') // => false

API

This package exports the following identifiers: isWordCharacter. There is no default export.

isWordCharacter(character|code)

Check whether the given character code (number), or the character code at the first position (string), is a word character.

Related

License

MIT © Titus Wormer