User name with a-z A-Z 0-9, and spaces?
Moderator: General Moderators
Re: User name with a-z A-Z 0-9, and spaces?
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/
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?
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?
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?
onion2k, I think this answer is for another thread.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.
viewtopic.php?f=19&t=88158
There are 10 types of people in this world, those who understand binary and those who don't
Re: User name with a-z A-Z 0-9, and spaces?
Code: Select all
^[A-z](\w|(\s)(?!.*\2))+\w$There are 10 types of people in this world, those who understand binary and those who don't
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: User name with a-z A-Z 0-9, and spaces?
^[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/
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/
- prometheuzz
- Forum Regular
- Posts: 779
- Joined: Fri Apr 04, 2008 5:51 am
Re: User name with a-z A-Z 0-9, and spaces?
That regex does not do what you posted in your original post.JAB Creations wrote:^[a-zA-Z][a-zA-Z0-9]*[a-zA-Z]$
19 Steps on "JABCreations"
...
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: User name with a-z A-Z 0-9, and spaces?
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.prometheuzz wrote:That regex does not do what you posted in your original post.
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?
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.JAB Creations wrote:For example I consider "jabcreations" and "JAB Creations" the same thing.
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Re: User name with a-z A-Z 0-9, and spaces?
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?
Yes. But they are similar, so that's perfectly correct.JAB Creations wrote:In regards to SOUNDEX() would "Robert" and "Rupert" be considered the same name?