0

Possible Duplicate:
Converting ereg expressions to preg

I've tried to convert but I keep failing.

My ereg: if (!ereg("^[a-zA-Z0-9]{3,16}$",$username)) {

is wrong because it is out of date. How do I switch it to preg_match?

Community
  • 1
  • 1
test
  • 17,706
  • 64
  • 171
  • 244
  • Have you tried replacing `ereg` with `preg_match`? You need to tell us _what_ you've tried, instead of "I've tried to convert...". – Bojangles Dec 05 '11 at 20:49
  • http://docstore.mik.ua/orelly/webprog/pcook/ch13_02.htm http://stackoverflow.com/questions/1374881/how-to-change-phps-eregi-to-preg-match http://php.net/manual/en/function.preg-match.php – Kenaniah Dec 05 '11 at 20:50

1 Answers1

5
if (!preg_match("/^[a-zA-Z0-9]{3,16}$/",$username)) { /* .. */ }

Note the delimiters /.

KingCrunch
  • 128,817
  • 21
  • 151
  • 173