Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kevinokerlund/dom-regex
JavaScript library for querying DOM elements with Regular Expressions.
https://github.com/kevinokerlund/dom-regex
dom dom-regex javascript-library queryselector regular-expression
Last synced: 18 days ago
JSON representation
JavaScript library for querying DOM elements with Regular Expressions.
- Host: GitHub
- URL: https://github.com/kevinokerlund/dom-regex
- Owner: kevinokerlund
- License: mit
- Created: 2016-07-20T17:35:19.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-01-23T02:38:47.000Z (about 8 years ago)
- Last Synced: 2024-12-22T22:34:27.637Z (about 2 months ago)
- Topics: dom, dom-regex, javascript-library, queryselector, regular-expression
- Language: JavaScript
- Homepage:
- Size: 48.8 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dom-regex
A JavaScript library for querying DOM elements with Regular Expressions.This library is UMD wrapped so it can be used with or without a module loader such as requireJS.
## Install
```shell
npm install --save dom-regex
```_**Note:**_ If this library is exposed directly to the window, it operates under the global variable `DomRegex`. Keep
in mind you may be in an environment (ex: webpack) that requires you explicitly expose it to the window if you intend
to use if from a window perspective.## Example Usage
```javascript
let DomRegex = require('dom-regex');// find all elements with any data- attribute
let elements = DomRegex.all(/data-[a-z]/);
```---
The following examples and methods behave like `querySelectorAll` and `querySelector`. The methods that use `all`
return all matching instances. The methods that use `one` return only the first instance found.## Querying through all the elements on the window
**Methods:**
`DomRegex.all(regex [, attributeName])`
`DomRegex.one(regex [, attributeName])`When not using an attribute name, the regex is applied to the entire inside contents of the element's opening tag. If
the tag is `