https://github.com/kevva/import-regex
Regular expression for matching CSS @imports
https://github.com/kevva/import-regex
css import javascript nodejs regex
Last synced: over 1 year ago
JSON representation
Regular expression for matching CSS @imports
- Host: GitHub
- URL: https://github.com/kevva/import-regex
- Owner: kevva
- License: mit
- Created: 2014-08-31T14:44:03.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-12-09T19:31:35.000Z (over 8 years ago)
- Last Synced: 2025-03-17T19:11:42.664Z (over 1 year ago)
- Topics: css, import, javascript, nodejs, regex
- Language: JavaScript
- Size: 9.77 KB
- Stars: 9
- Watchers: 6
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# import-regex [](https://travis-ci.org/kevva/import-regex)
> Regular expression for matching CSS @imports
## Install
```
$ npm install --save import-regex
```
## Usage
```js
const importRegex = require('import-regex');
importRegex().test('@import url(\'foo.css\'); foo bar');
//=> true
importRegex({exact: true}).test('@import url(\'foo.css\'); foo bar');
//=> false
importRegex({exact: true}).test('@import url(\'foo.css\');');
//=> true
'foo @import url(\'foo.css\'); bar @import url(\'bar.css\');'.match(importRegex());
//=> ['@import url('foo.css');', '@import url('bar.css');']
```
## API
### importRegex([options])
Returns a regex for matching CSS @imports.
#### options
Type: `Object`
##### exact
Type: `Boolean`
Default: `false`
Only match an exact string. Useful with `RegExp#test` to check if a string is a CSS @import.
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)