[PHP] [newbie] Can I use regular expressions?

2001-02-11 Thread zbynek
Hi there! I want to check if given username consists only of letters of English alphabet, numbers, or "_". I can go through the string and check every character. Wouldn't it be simpler to use regular expressions? How would I do it? These usernames are OK: _john_, 0123bla, foo These are wrong:

Re: [PHP] [newbie] Can I use regular expressions?

2001-02-11 Thread Christian Reiniger
On Sunday 11 February 2001 13:09, zbynek wrote: I want to check if given username consists only of letters of English alphabet, numbers, or "_". Wouldn't it be simpler to use regular expressions? How would I do it? if (preg_match ('/^\w+$/', $Username)) echo "'$Username' is okbr";