问题 I need a (php) regex to match Yahoo's username rules: Use 4 to 32 characters and start with a letter. You may use letters, numbers, underscores, and one dot (.). 回答1: /^[A-Za-z](?=[A-Za-z0-9_.]{3,31}$)[a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*$/ Or a little shorter: /^[a-z](?=[\w.]{3,31}$)\w*\.?\w*$/i 回答2: /[a-zA-Z][a-zA-Z0-9_]*\.?[a-zA-Z0-9_]*/ And check if strlen($username) >= 4 and <= 32. 回答3: A one dot limit? That's tricky. I'm no regex expert, but I think this would get it, except for that: [A-Za-z]