Forum > Packages and Libraries

TRegExpr - Idfficulty using expressions found from elsewhere

(1/3) > >>

Gizmo:
Hi

Using TRegExpr (http://regexpstudio.com) I am struggling to use some of the example RE's on the net for, in this case, validating strong passwords (i.e. mix of upper and lower case with at least one number etc) though I have struggled with some other examples too as there seems to be so many variances for what I thought was fairly standard 'language'. Anyway, I have found several examples for strong passwords but cannot get any of them to work with TRegExpr. For example:

^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{6,50}$ (http://regexhero.net/library/35/strong-password)
or
 /^(?=^.{6,}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z]))^.*$/ (http://regexhero.net/library/35/strong-password)

When I run the program I usually get 'Unrecognised modifier (Pos X)'

Many thanks for any advice

Ted

BigChimp:
To put it bluntly: split out the regexes into the smallest parts that don't work. Compare with documentation (e.g. http://regexpstudio.com/TRegExpr/Help/RegExp_Syntax.html) to see if that syntax is supported. File a bug if it should be.

ludob:
There are several incompatible regex dialects. The (?= is a lookahead assertion used in the PHP (PCRE) dialect. TRegExpr is close to the PERL regex syntax and doesn't support (?=

The document mentioned by BigChimp shows that (? is interpreted as an inline modifier which explains the error message.

Gizmo:
I've decided to try and start from scratch following the link provided by BC.

So, the following works quite well : [A-Za-z]{6,}[0-9]{1,}

will find things like TedSmith28 but not Ted-Smith28 or T3dSm1th28....will keep trying:-) It's like another language in itself!

Martin_fr:
I haven't tested it, and I hope I did not put typos in there.


But the below (all on ONE line / NO spaces) should test that lower, upper and digits are all present (in any order)

It does NOT check any minimum length. (Can be added, but will make the pattern much more complex)


(.* [A-Z] .* ( ([a-z].*[0-9]) | ([0-9].* [a-z]) ) .* ) |
(.* [a-z] .*  ( ([A-Z].*[0-9]) | ([0-9].* [A-Z]) ) .* ) |
(.* [0-9] .*  ( ([a-z].*[A-Z]) | ([A-Z].* [a-z]) ) .* )

Navigation

[0] Message Index

[#] Next page

Go to full version