Preg_match: Regular Expression used to determine the user name

Source: Internet
Author: User



Problem
Judge the regular expression of the user name
Solution
Preg_match ('/^ \ s * $ | ^ c: \ con $ | [%, \ * \ "\ s \ t \ <\> \ & '\]/', $ username)


How Can I copy the code?

Thank you!

Copy the PHP content to the clipboard. PHP code: [%, * "\ s \ t \ <\> \ & '\]


This part can be basically understood, *, double quotation marks, space characters, tabs, less than, greater than, &, single quotation marks, but why use two backlash?

What do we mean by the last four backslash lines?

[]


Reference answer
[Img] http://www.111cn.cn/bbs/images/smilies/default/funk.gif#/img]
Reference answer
The user name is prohibited from being signed. Blank characters and line breaks.

It seems that the regular expression author is a little abnormal.
Reference answer
I don't know much.
^ \ S * $ | ^ c :.
^
Why use two \ s?
C:
What does it mean?
Reference answer
/^

The most strange thing is here. ^ put it in the middle of the expression. I really don't think of what it means ..
Reference answer
\ S *

Why should we use two \
This is a single quotation mark. Simply say one is enough.
Reference answer
Du Jiang's book has said that \ s \ t \ r all have...
Reference answer
Can't you answer this question in front of me? [img] http://www.111cn.cn/bbs/images/smilies/default/42.gif#/img]
Reference answer
\ Con what is this?
Reference answer
Can you tell me what you know?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.