Yes, in this particular example one can rewrite the expression as ^.*(([a-zA-Z].*[0-9])|([0-9].*[a-zA-Z])).*$ and it (probably) does the same. However, this cannot be done in a general case, because lookahead are not part of the (currently) recognizable types of languages with VB-Regexp. It shouldn't be too difficult to add positive and negative lookahead to VB-Regexp (this is essentially like #and and #not in PetitParser), but getting the semantics exactly right is more tricky. Lukas On 12 February 2012 15:40, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
thanks for the update. Now may be the problem can be still express with regex.
Stef
On Feb 12, 2012, at 10:49 AM, Lukas Renggli wrote:
VB-Regexp does not support any of the following common regular expression features: lookahead, lookbehind, recursion, multiplicity ranges, non-greedy quantifier, shy groups, directives, conditionals, named captures, back references, and comments.
You can (conceptually) do all this with PetitParser, but then you are not writing a regular expression anymore but a (PEG) parser.
There was once a plugin that called an external regular expression library (I think it used the library Perl is using) that supported the features you are looking for.
Lukas
On 11 February 2012 23:27, Â <recursive68@gmail.com> wrote:
Hi,
Is it possible to use the VB-Regexp package to construct a single regular expression that ensures a string is alphanumeric and contains both at least one number and alphabetic character.
Looking at the regexp package and documentation it doesn't appear so. In javascript or perl you use something like this with lookahead assertions:
^(?=.*[a-zA-Z])(?=.*[0-9]).*$
I have something working using multiple regexp's but wondered if a more typical regexp was possible using the package ?
Thanks
-- Lukas Renggli www.lukas-renggli.ch
-- Lukas Renggli www.lukas-renggli.ch