jehna/VerbalExpressions — pull request #17 by go-oleg (2013-07-23 02:39:23+00:00)
Title: Add beginCapture and endCapture

Hi,

First off, this tool is a great idea!!!

About this PR:

I added `beginCapture` and `endCapture` functions to support capturing groups. Here is an example:
```javascript
var tester = VerEx()
.startOfLine().beginCapture()
.then( "http" )
.maybe( "s" ).endCapture()
.then( "://" )
.maybe( "www." ).beginCapture()
.anythingBut( " " ).endCapture()
.endOfLine();

var matches = tester.exec("https://www.google.com")
//matches: ["https://www.google.com", "https", "google.com"]
```
To achieve this, I also changed all other `(` used in the code to non-capturing ones `(?:` so that the regex wouldn't capture anything the user did not expect.

Please be sure to review my changes to the `or` function since I removed the extra check on `this._prefixes` and `this._suffixes` because I couldn't quite figure out what usecase those were addressing.

Overall, this pattern is a slight divergence from what you have going right now in that it takes two function calls to achieve something. The other option would be to make it more like `or()` behaves and have a `capture()` function that just captures everything before it. However, I think `beginCapture()`/`endCapture()` is a bit more flexible and allows you to have multiple separate capturing groups which is probably pretty common.

Please let me know what you think. I'd be happy to add info to `README.md` and the wiki if you plan on merging it.

Thanks,
Oleg

PS - If you like these functions, I was thinking we could even take it a step further and allow users to pass in a `name` into `beginCapture` and then provide a more user-friendly way of accessing the captured values than the array returned by `exec()`.