Skip to content

Instantly share code, notes, and snippets.

@ibiwan
Created August 16, 2015 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ibiwan/f9df9e6a2dbb1abaa036 to your computer and use it in GitHub Desktop.
Save ibiwan/f9df9e6a2dbb1abaa036 to your computer and use it in GitHub Desktop.
var template = "(a{1,3})12(?:b|3)(\\d*?)(\\d+)";
var rb = new reBuilder();
rb.build(
rb.capture(
rb.repeat(1, 3, true, 'a') // third parameter is isGreedy
),
'12',
rb.repeat(0, 1, true,
rb.or(
'b',
'3'
)
),
rb.capture(
rb.repeat(0, Infinity, false,
rb.charDigit()
)
),
rb.named(
'digits',
rb.repeat(1, Infinity, true,
rb.charDigit()
)
)
);
var re = rb.generate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment