Page 2 of 2
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Mon Sep 15, 2008 3:50 am
by Zoxive
http://en.wikipedia.org/wiki/Regular_expression
You can also google regex etc.. to find more and learn what does what.
I can pretty much tell you everyone here helping you right now, has learned through trying it & searching internet.
Some online regex tools i like:
http://regex.larsolavtorvik.com/ ,
http://regexpal.com/
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Mon Sep 15, 2008 7:48 am
by GeertDD
I would probably break down validation in multiple steps. Even though you probably can create a regex that checks for the amount of spaces, letters and string length, I think using native php functions like substr_count() and mb_strlen() in combination with one simple regex would keep your code readable and your regex fast.
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Mon Sep 15, 2008 7:58 am
by onion2k
Are you seriously intending to do a regular expression check against every username in your database to make sure there aren't any similar ones? I do hope the system never gets popular, it'll be hellishly slow.
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Mon Sep 15, 2008 8:31 am
by VladSun
onion2k wrote:Are you seriously intending to do a regular expression check against every username in your database to make sure there aren't any similar ones? I do hope the system never gets popular, it'll be hellishly slow.
onion2k, I think this answer is for another thread.
viewtopic.php?f=19&t=88158
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Mon Sep 15, 2008 9:07 am
by VladSun
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Mon Sep 15, 2008 4:50 pm
by JAB Creations
^[a-zA-Z][a-zA-Z0-9]*[a-zA-Z]$
19 Steps on "JABCreations"
^(?!(\S* ){2})[a-zA-Z][a-zA-Z\d\s]*$
48 Steps on "JABCreations"
Like VladSun kindly suggested download The Regex Coach.
http://www.weitz.de/regex-coach/
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Tue Sep 16, 2008 12:08 pm
by prometheuzz
JAB Creations wrote:^[a-zA-Z][a-zA-Z0-9]*[a-zA-Z]$
19 Steps on "JABCreations"
...
That regex does
not do what you posted in your original post.
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Tue Sep 16, 2008 3:26 pm
by JAB Creations
prometheuzz wrote:That regex does not do what you posted in your original post.
True however I'm thinking of creating a second MySQL column where letter casing is converted to lower case and spaces are stripped. I've been sort of feeling my way in my head with the discussions we've had here. One of the other threads we have been discussing about how to prevent for practical purposes the same name. For example I consider "jabcreations" and "JAB Creations" the same thing. I know Linux-heads don't like this as even a single different letter casing is considered different. However Linux doesn't get people and people don't get Linux in this regards and I have the steps worked out to minimize server load as much as possible at least on my current skill level.
Thank you for your input of course! I have messed with The Regex Coach's steps tab with all the regex strings posted here trying to minimize the steps needed. Frankly you should only be peeved if I simply copied and pasted your regex suggestion because then I would clearly have no interest in learning to do it on my own and to of course get better at it. I think my slightly shifting goals are well within reason. For me I learn best with multiple working examples. They don't have to be exactly what I need or want but as long as they work I can learn from them. Thanks again!

Re: User name with a-z A-Z 0-9, and spaces?
Posted: Tue Sep 16, 2008 4:31 pm
by onion2k
JAB Creations wrote:For example I consider "jabcreations" and "JAB Creations" the same thing.
Can I just ask ... why didn't you go with the SOUNDEX() solution I posted? It really would be perfect for what you're talking about. And fast, especially if you stored the SOUNDEX() value when you created the user record.
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Tue Sep 16, 2008 7:25 pm
by JAB Creations
In regards to SOUNDEX() would "Robert" and "Rupert" be considered the same name?
Re: User name with a-z A-Z 0-9, and spaces?
Posted: Sun Sep 21, 2008 3:03 pm
by onion2k
JAB Creations wrote:In regards to SOUNDEX() would "Robert" and "Rupert" be considered the same name?
Yes. But they
are similar, so that's perfectly correct.