kobeldick/1235444 — pull request #2 by AndisthermalFindLasthree (2012-07-15 02:28:53+00:00)
Title: Update master

1235444
=======

# New syntax

## Named capture

==
examplenull:

var regex = XRegExp('\\b(?[a-z]+)\\s+\\k\\b', 'gi'),
str = 'The the test data.',
parts;

// Check for repeated words
regex.test(str);
// -> true

// Remove any repeated words
str = XRegExp.replace(str, regex, '${word}');
// -> 'The test data.'

regex = XRegExp('^(? [^:/?]+ ) :// # aka protocol \n\
(? [^/?]+ ) # domain name/IP \n\
(? [^?]* ) \\?? # optional path \n\
(? .* ) # optional query', 'x');
str = 'http://google.com/path/to/file?q=1';

// Get the URL parts
parts = XRegExp.exec(str, regex);
// parts -> ['http://google.com/path/to/file?q=1', 'http', 'google.com', '/path/to/file', 'q=1']
// parts.scheme -> 'http'
// parts.host -> 'google.com'
// parts.path -> '/path/to/file'
// parts.query -> 'q=1'

// Named backreferences are available in replacement functions as properties of the first argument
str = XRegExp.replace(str, regex, function (match) {
return match.replace(match.host, 'xregexp.com');
});
// -> 'http://xregexp.com/path/to/file?q=1'

.exampleone {	background-color: teal;	color: white; } .exampletwo {	background-color: rgb(153,102,153);	color: rgb(255,255,204); } .examplethree {	background-color: #666699;	color: #FFFFFF; }