Question about code understanding

Source: Internet
Author: User
May I ask questions about the code understanding, could you tell me the following red code preg_match ('/[^ a-z0-9 _]/I', $ act) should be how to understand? Thank you for your help.


$ Act = Get ('Act ');
If (! Isset ($ act {0 })){
$ Act = 'Pa ';
} Elseif (preg_match ('/[^ a-z0-9 _]/I', $ act )){
Exit;
}


Reply to discussion (solution)

/[^ A-z0-9 _]/I
Match characters other than letters, numbers, and underscores

Preg_match ('/[^ a-z0-9 _]/I', $ act

Preg_match is a php regular expression matching method.
'/[^ A-z0-9 _]/I' is a matching regular expression
$ Act is a string used to check for matching

Regular Expression Description
A-z indicates that all lowercase letters are matched.
0-9 indicates matching numbers 0 ~ 9
_ Matches the underline

The entire sentence indicates whether $ act is composed of lower-case letters, numbers, or Underscores. if it is true, it is false.

Could you tell me the following red code preg_match ('/[^ a-z0-9 _]/I', $ act) How should I understand? Thank you for your help.


$ Act = Get ('Act ');
If (! Isset ($ act {0 })){
$ Act = 'Pa ';
} Elseif (preg_match ('/[^ a-z0-9 _]/I', $ act )){
Exit;
}



Thank you for your reply.

/[^ A-z0-9 _]/I
Match characters other than letters, numbers, and underscores



Thank you for your reply to fdipzone.
I basically understand the meaning of this code.
However, I have another question:

The entire sentence indicates whether $ act is composed of lower-case letters, upper-case letters, numbers, or Underscores. if it is true, otherwise it is false.
Because the regular expression is followed by/I

Is that true?

Preg_match ('/[^ a-z0-9 _]/I', $ act

Preg_match is a php regular expression matching method.
'/[^ A-z0-9 _]/I' is a matching regular expression
$ Act is a string used to check for matching

Regular Expression Description
A-z indicates that all lowercase letters are matched.
0-9 indicates matching numbers 0 ~ 9
_ Matches the underline

The entire sentence indicates whether $ act is composed of lower-case letters, numbers, or Underscores. if it is true, it is false.



Thank you for your reply.
I basically understand the meaning of this code.
However, I have another question:

The entire sentence indicates whether $ act is composed of lower-case letters, upper-case letters, numbers, or Underscores. if it is true, otherwise it is false.
Because the regular expression is followed by/I

Is that true?

If (preg_match ('/[^ a-z0-9 _]/I', $ act )){
Exit;
}
If $ act contains characters other than letters, numbers, and underscores, exit


Preg_match ('/[^ a-z0-9 _]/I', $ act

Preg_match is a php regular expression matching method.
'/[^ A-z0-9 _]/I' is a matching regular expression
$ Act is a string used to check for matching

Regular Expression Description
A-z indicates that all lowercase letters are matched.
0-9 indicates matching numbers 0 ~ 9
_ Matches the underline

The entire sentence indicates whether $ act is composed of lower-case letters, numbers, or Underscores. if it is true, it is false.



Thank you for your reply.
I basically understand the meaning of this code.
However, I have another question:

The entire sentence indicates whether $ act is composed of lower-case letters, upper-case letters, numbers, or Underscores. if it is true, otherwise it is false.
Because the regular expression is followed by/I

Is that true?


Yes.

You can find and learn simple regular expressions.

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.