Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/github30/cc-regex
'[email protected]'.match(/\x{email}/)
https://github.com/github30/cc-regex
charactors class email prefecture regex regexp regular-expression url
Last synced: 3 months ago
JSON representation
'[email protected]'.match(/\x{email}/)
- Host: GitHub
- URL: https://github.com/github30/cc-regex
- Owner: GitHub30
- License: mit
- Created: 2022-08-15T00:56:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-15T12:47:22.000Z (over 2 years ago)
- Last Synced: 2024-10-30T03:42:41.224Z (3 months ago)
- Topics: charactors, class, email, prefecture, regex, regexp, regular-expression, url
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/cc-regex
- Size: 40 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![npm version](https://badge.fury.io/js/cc-regex.svg)](https://badge.fury.io/js/cc-regex)
# cc-regex
Regular expression for Character classes## Usage
### Find an email address
```javascript
'[email protected]'.match(/\x{email}/g)
// ['[email protected]']
```### Find a URL
```javascript
'https://example.com/foo/bar'.match(/\x{url}/g)
// ['https://example.com/foo/bar']
```### Find a 都道府県
```javascript
'島根県にパソコンなんてあるわけないじゃん'.match(/\x{都道府県}/g)
// ['島根県']
```### Find a IP address
```javascript
'127.0.0.1'.match(/\x{ip}/g)
// ['127.0.0.1']
```### Find a FQDN
```javascript
'example.com sub.example.com'.match(/\x{fqdn}/g)
// ['example.com', 'sub.example.com']
```### Find a Location
```javascript
const str = '時どき私はそんな路を歩きながら、ふと、そこが京都ではなくて京都から何百里も離れた仙台とか長崎とか――そのような市へ今自分が来ているのだ――という錯覚を起こそうと努める。'
await str.matchAsync(/\x{場所}/g)
// ['京都', '京都', '仙台', '長崎']
```### Find a Person
```javascript
const str = '昨日、ジョンと山田太郎は松のやでカツ丼を食した。'
await str.matchAsync(/\x{人物}/g)
// ['ジョン', '山田太郎']
```## Install
```bash
npm install cc-regex
```![image](https://user-images.githubusercontent.com/12811398/184637627-af99820e-40e6-4bd3-99ea-aba73a27fcab.png)
### for browser
```html
```