Home > Backend Development > PHP Tutorial > preg_match regular expression to determine user name_PHP tutorial

preg_match regular expression to determine user name_PHP tutorial

WBOY
Release: 2016-07-13 10:51:04
Original
1056 people have browsed it



Question
Regular expression to determine username
Solution
preg_match('/'/^s*$|^c:\con\con$|[%,*"st&'\]/', $username)


How do you understand copying code?

Thank you everyone

Copy PHP content to clipboard PHP code: [%,*"st&'\]


This part can basically be understood, asterisk, double quotation mark, space character, tab character, less than, greater than, &, single quotation mark, but why use two backslashes?

And what do the last four backslashes mean?

[ ]


Reference answer
[img]http://www.111cn.cn/bbs/images/smilies/default/funk.gif[/img]
Reference answer
Usernames with symbols, whitespace characters, and line breaks are prohibited.

I feel like the regular author is a bit perverted.
Reference answer
I don’t quite understand..Explain.
^s*$|^c:.
^ What does it mean
Why use two s
c:
What does it mean again
Reference answer
/^

The strangest thing is here. ^ is placed in the middle of the expression, I really can’t think of what it means..
Reference answer
s*

Then why use two
here? This is a single quote. Logically speaking, one is enough
Reference answer
Du Jiang's book has talked about it. s t r are all there...
Reference answer
Can’t you answer directly? [img]http://www.111cn.cn/bbs/images/smilies/default/42.gif[/img]
Reference answer
con\con What does this do?
Reference answer
Can you tell me what you know?

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632587.htmlTechArticleRegular expression solution to the problem of judging username preg_match('/'/^s*$|^c: \con\con$|[%,*"st '\] This part can basically be understood, * sign, double quotation mark, space character, tab character,...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template