filename-reserved-regex
Regular expression for matching reserved filename characters
Last updated 10 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install filename-reserved-regex 
SYNC missed versions from official npm registry.

filename-reserved-regex

Regular expression for matching reserved filename characters

On Unix-like systems / is reserved and <>:"/\|?* as well as non-printable characters \u0000-\u001F on Windows.

Install

$ npm install filename-reserved-regex

Usage

import filenameReservedRegex, {windowsReservedNameRegex} from 'filename-reserved-regex';

filenameReservedRegex().test('foo/bar');
//=> true

filenameReservedRegex().test('foo-bar');
//=> false

'foo/bar'.replace(filenameReservedRegex(), '!');
//=> 'foo!bar'

windowsReservedNameRegex().test('aux');
//=> true

API

filenameReservedRegex()

Returns a regex that matches all invalid characters.

windowsReservedNameRegex()

Returns an exact-match case-insensitive regex that matches invalid Windows filenames. These include CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8 and LPT9.

Current Tags

  • 3.0.0                                ...           latest (3 years ago)

3 Versions

  • 3.0.0                                ...           3 years ago
  • 2.0.0                                ...           8 years ago
  • 1.0.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 1
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)
Dependents (2)

Copyright 2013 - present © cnpmjs.org | Home |