tags:

views:

34

answers:

2

Hi, Please tell me the pattern to validate a twitter handler using preg_match

Thanks

+1  A: 

Twitter allows you to use letters, numbers, and '_', so

preg_match("/[a-z0-9_]+/i", username)

for a case-insensitive search with at least one character.

greg
+1  A: 

I think greg forgot the "@" that indicates the beginning of a twitter handler:

preg_match("/\@[a-z0-9_]+/i", $username);
Marcio Almada