Skip to content

Instantly share code, notes, and snippets.

Margaret Moser margaretmoser

Block or report user

Report or block margaretmoser

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@slevithan
slevithan / xregexp-lookbehind2.js
Created Apr 14, 2012
Simulating lookbehind in JavaScript (take 2)
View xregexp-lookbehind2.js
// Simulating infinite-length leading lookbehind in JavaScript. Uses XRegExp.
// Captures within lookbehind are not included in match results. Lazy
// repetition in lookbehind may lead to unexpected results.
(function (XRegExp) {
function prepareLb(lb) {
// Allow mode modifier before lookbehind
var parts = /^((?:\(\?[\w$]+\))?)\(\?<([=!])([\s\S]*)\)$/.exec(lb);
return {
You can’t perform that action at this time.