Update: Some of the functionality discussed here has made its way into later versions of XRegExp.
So, I'll admit that XRegExp 0.1, though hopefully interesting or useful for some people, was scaled back from my original plans. There were two reasons for this:
- To get it out the door.
However, if I don't worry about the regexes being used with built-in methods, and instead create custom methods (possibly with names like
xexec, etc.), a number of significant, additional features become technically possible to mimic. Things like atomic groups, possessive quantifiers, named capture, and even infinite-length lookbehinds (though lookbehinds would have to be limited to appearing at the start and/or end of regexes, or alternatively not be used together with lookaheads).
I wouldn’t worry about the rest of the stuff for now. My regex needs are still pretty basic. I’d say work on it if need arises.
Boyan, I tend to agree with your take on this (i.e., not working on it until there’s a need). However, it’s pretty unlikely I’ll ever run into a personal need, since manually mimicking features on a case-by-case basis is generally a lot easier up front than automating the process.
As for Cruiser, yeah, it’s interesting. I actually saw it a few days ago on Ajaxian, and I’ve left several comments on the page you linked to (although my regexes in the first comment there are missing a bunch of characters due to the Textile auto-formatting in place).
Is there any function which allows you to find out if a string is a valid prefix of a regex and what the valid lookahead characters are after the prefix? My use is in validating form input fields: after a new character is added to the field, run the field contents through the field’s validation regex. If the character causes the regex to fail, then remove the character from the field. Additionally, if the field has only one valid lookahead character, add that lookahead to the field.
For example, validate a telephone number and automatically fill in the dashes (‘-‘).