https://github.com/jlobos/rut-regex
Regular expression for matching Chile RUT's
https://github.com/jlobos/rut-regex
chile regex rut
Last synced: 11 months ago
JSON representation
Regular expression for matching Chile RUT's
- Host: GitHub
- URL: https://github.com/jlobos/rut-regex
- Owner: jlobos
- License: mit
- Created: 2017-08-08T19:20:56.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-02-19T11:38:24.000Z (over 5 years ago)
- Last Synced: 2025-04-20T00:42:23.571Z (about 1 year ago)
- Topics: chile, regex, rut
- Language: JavaScript
- Homepage: https://npmjs.com/rut-regex
- Size: 38.1 KB
- Stars: 10
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# rut-regex
> Regular expression for matching Chile RUT's
## Install
```bash
$ npm install --save rut-regex
```
## Usage
```js
const rutRegex = require('rut-regex')
rutRegex().test('Felipito 8.714.763-0')
// true
rutRegex().test('8.714.763-0 Felipito')
// true
rutRegex({exact: true}).test('Felipito 8.714.763-0')
// false
rutRegex({exact: true}).test('8.714.763-0')
// true
rutRegex({exact: true, dot: false}).test('8714763-0')
// true
rutRegex({exact: true, dot: false, hyphen: false}).test('87147630')
// true
'Ganadores 8.714.763-0 18.972.631-7 :tada:'.match(rutRegex())
// [ '8.714.763-0', '18.972.631-7' ]
```
## API
### rutRegex(options)
Returns a regex for matching Chile RUT's.
#### options
Type: `Object`
##### exact
Type: `boolean`
Default: `false`
Only match an exact string. Useful with `RegExp#test` to check if a string is a RUT.
##### dot
Type: `boolean`
Default: `true`
Dot (.) in RUT.
##### hyphen
Type: `boolean`
Default: `true`
Hyphen (-) in RUT.
## Related
- [rut.js](https://github.com/jlobos/rut.js) - Sencilla y pequeña librería para validar y dar formato al RUT