mdpauley / ti-xregexp

XRegExp for Titanium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ti-xregexp

XRegExp 2.0.0 for Appcelerator Titanium

This is a [titaniumified][ti] version of XRegExp. This is built using grunt-titaniumifier.

Installation

If you are developing a Titanium SDK application, a packaged CommonJS module can be found in the Releases page.

If you are instead

  • porting with titaniumifier a Node.js module to Titanium, and it uses XRegExp;
  • or building CommonJS module using titaniumifier and you want to have a reliable, stable, tested HTTPClient;

then you can install this module with

npm install --save xregexp ti-xregexp

In your package.json add

{
  "name": "...",
  "version": "...",
  // ...
  "titanium": {
    "xregexp": "ti-xregexp"
  }
}

This will tell titaniumifier that when your code requires xregexp, ti-xregexp is served instead.

You can use this package.json from one of our modules as a reference.

Usage overview

For the full documentation head over the original repository.

var xregexp = require('xregexp').XRegExp;

// Using named capture and flag x (free-spacing and line comments)
date = XRegExp('(?<year>  [0-9]{4} ) -?  # year  \n' +
               '(?<month> [0-9]{2} ) -?  # month \n' +
               '(?<day>   [0-9]{2} )     # day     ', 'x');

XRegExp.exec('2012-06-10', date).year;
// -> '2012'

// Matchception: Finding matches within matches, while passing forward and
// returning specific backreferences
html = '<a href="http://xregexp.com/api/">XRegExp</a>' +
       '<a href="http://www.google.com/">Google</a>';
XRegExp.matchChain(html, [
  {regex: /<a href="([^"]+)">/i, backref: 1},
  {regex: XRegExp('(?i)^https?://(?<domain>[^/?#]+)'), backref: 'domain'}
]);
// -> ['xregexp.com', 'www.google.com']

About

XRegExp for Titanium

License:GNU Lesser General Public License v2.1


Languages

Language:JavaScript 100.0%