[thelist] regex help - password pattern - javascript

Frank lists at frankmarion.com
Tue Sep 27 07:03:38 CDT 2005


At 12:48 AM 2005-09-27, you wrote:
>Why not split our problem and use two reg exps?


That's certainly an idea. I get the sense that he's wanting to do it in all 
one shot because

1) Maybe it simplifies things (visually)
2) It's an interesting puzzle.
3) Regex is simply cool stuff to work-out.

Of course the simplest way is simply to use js to 1) check for the length, 
then check for two alphas then two numerics. Easier, but not as interesting.

I've been working at it all last night, to roll it into one single regex 
without much luck. What I have figured out is that regardless of the 
string, a match will always have the following criteria

an alpha and a numeric will always be side to side. This will catch it

[a-z_][0-9]|[0-9][a-z_]
<group alpha fb number OR number fb alpha>

The problem is that there might be a run of non-matches before, or 
following, or between each of these pairs. One might be inclined to say 
"Ah! Then the solution is to add {2}. Not so, because then it would return 
the match of a1a1 but not a1xa1.

This is the crux of the problem, as I've been able to figure so far.

My suggestion: if this is a puzzle, keep at it. If it's work, use the 
conventional way.



Frank Marion     lists at frankmarion.com      Keep the signal high.





More information about the thelist mailing list