Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ffxsam/meteor-xregexp
Augmented and extensible JavaScript regex
https://github.com/ffxsam/meteor-xregexp
Last synced: about 1 month ago
JSON representation
Augmented and extensible JavaScript regex
- Host: GitHub
- URL: https://github.com/ffxsam/meteor-xregexp
- Owner: ffxsam
- Created: 2015-09-26T02:34:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-27T00:55:55.000Z (over 9 years ago)
- Last Synced: 2024-11-11T15:50:15.307Z (3 months ago)
- Language: JavaScript
- Size: 121 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# XRegExp
XRegExp is an open source (MIT License) JavaScript library that provides augmented (and extensible!) regular expressions. You get new modern syntax and flags beyond what browsers support natively. XRegExp is also a regex utility belt with tools to make your client-side grepping and parsing easier, while freeing you from worrying about pesky cross-browser inconsistencies and things like manually manipulating `lastIndex` or slicing strings when tokenizing.
**XRegExp lets you write regexes like this:**
```javascript
// Using named capture and flag x (free-spacing and line comments)
date = XRegExp('(? [0-9]{4} ) -? # year \n' +
'(? [0-9]{2} ) -? # month \n' +
'(? [0-9]{2} ) # day ', 'x');
```**And do cool stuff like this:**
```javascript
// Using named backreferences...
XRegExp.exec('2012-06-10', date).year;
// -> '2012'
XRegExp.replace('2012-06-10', date, '${month}/${day}/${year}');
// -> '06/10/2012'// Finding matches within matches, while passing forward and returning specific backreferences
html = 'XRegExp' +
'Google';
XRegExp.matchChain(html, [
{regex: //i, backref: 1},
{regex: XRegExp('(?i)^https?://(?[^/?#]+)'), backref: 'domain'}
]);
// -> ['xregexp.com', 'www.google.com']
```Check out more [usage examples on GitHub](https://github.com/slevithan/xregexp/blob/master/README.md).