Regular expression match title

Regular expression match title

 

Range Address: HTTP: //**.**.***.**: 8010 / Re / the above mentioned id = 1? .

 

<?php   

$key='flag{********************************}';  

$Regular=preg_match("/zkaq.*key.{2,9}:\/.*\/(key*key)/i", trim($_GET["id"]), $match);  

if( $Regular ){   

  die('key: '.$key);  

}

 

Code explanation:

the preg_match ( regular expression matching string )

A first matching substring matching regular, not found returns 0 , found returns 1

trim ($ _ GET [ "id "])  to accept the ID string parameter passing over

 

 

 

if( $Regular ){  die('key: '.$key); }

if (1) {} performed;

if (0) {} is not performed;

die (); prints a message and exits the current script.

This is a function  exit ()  alias function.

 

Problem-solving ideas : that the need to string the string matches the regular expression will return in line with Flag .

 

Regular expressions explained:

PHP regular expressions to write in / / between. 

. : In addition to matching a newline \ n beyond any single character. 

* : Matches the preceding subexpression zero or more times. 

n { ,} m: m and n are non-negative integers, where n <= m. Match at least n times and match up to m times. For example, "o {1,3}" will match "fooood" in the previous three o. Please note that no spaces between the comma and the two numbers. 

\: The next character is marked as or special characters, or literals, or back-reference, or an octal escape. For example, 'n-' matches the character 'n'. '\ n' match a newline. Sequence '\\' match '\', and '\ (' matching the "(" . 

I: tag specifies case-insensitive.

  

/zkaq.*key.{2,9}:\/.*\/(key*key)/i

Split explain this regular expression

1.

/zkaq.*/: indicates "zkaq" behind 0- N number of any single character except a newline \ n a (N non-negative integer). 

zkaq (I can understand behind can not follow characters)

2.

/ Key {} 2,9 /:. Indicates " Key " are 2 back 9 of any single character except a newline \ n a. 

keyhello (I can, " Key added 2-9 characters after")

3.

/: \ /.* \ / /: first a ":". "*" For the colon character, "\ /" for the slash "/" in translation, followed represents 0- N in addition to a newline \ n of any single character outside the (N non-negative integer). 

: // (nothing to say, I can not add characters)

4.

/ ( Key * Key ) /: indicates "ke" and " Key there between 0-" N characters "y" (N is a nonnegative integer). 

keykey (I can not add characters)

combination:

zkaqkeyhello://keykey

Unicode encoding this: 

3A% zkaqkeyhello // KeyKey

 

 

Guess you like

Origin www.cnblogs.com/sx2960/p/11371898.html