Regex Go is a convenient package that provides some common regular expressions.
Install this package:
npm install regex-go --save
Use the APIs you need in your program, e.g.:
import { isDomain } from 'regex-go';
if (isDomain('google.com')) {
console.log('This is a domain!');
}
If you want to use ESModule version, you should need to import this package from regex-go/esm
, the default one is es moudle.
isDomain(s: string): boolean
If the string is a domain.
isEmail(s: string): boolean
If the string is an email address.
containsEmoji(s: string): boolean
Test if the string contains emoji. (the pattern comes from emoji-regex
)
containsChinese(s: string): boolean
Test if the string contains Chinese characters.
Just install the dependencies and run npm run build
.
MIT