3v4l.org

run code in 300+ PHP versions simultaneously
<?php function testRegExp($regexp, $string) { $valid = preg_match($regexp, $string); echo $string. " - " . ($valid ? "valid" : "invalid") ."\n"; } function matchRegExp($regexp, $text){ if(preg_match($regexp, $text, $matches)){ print_r($matches); }else{ echo "no match in text: ".$text; } echo "\n"; } // hledání emailu @seznam.cz v textu (zjednodušená verze) $regexpEmail = "/\b(?P<email>\w+@seznam\.cz)\b/"; matchRegExp($regexpEmail, "adsd dominik@seznam.cz ssdasd"); matchRegExp($regexpEmail, "adsd dominik@seam.cz ssdasd"); // validace IP adresy $regexpIp = "/^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$/"; echo "Test IP\n"; testRegExp($regexpIp, "10.1.0.1"); testRegExp($regexpIp, "199.1.0.1"); testRegExp($regexpIp, "255.1.0.1"); testRegExp($regexpIp, "256.1.0.1"); testRegExp($regexpIp, "260.1.0.1"); testRegExp($regexpIp, "300.1.0.1"); testRegExp($regexpIp, "1.0.1"); testRegExp($regexpIp, "125.1..1"); testRegExp($regexpIp, "192.11.168.255"); testRegExp($regexpIp, "192.11.168.256"); testRegExp($regexpIp, "192.11.168.300");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AkNH4
function name:  (null)
number of ops:  56
compiled vars:  !0 = $regexpEmail, !1 = $regexpIp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                   !0, '%2F%5Cb%28%3FP%3Cemail%3E%5Cw%2B%40seznam%5C.cz%29%5Cb%2F'
   19     1        INIT_FCALL                                               'matchregexp'
          2        SEND_VAR                                                 !0
          3        SEND_VAL                                                 'adsd+dominik%40seznam.cz+ssdasd'
          4        DO_FCALL                                      0          
   20     5        INIT_FCALL                                               'matchregexp'
          6        SEND_VAR                                                 !0
          7        SEND_VAL                                                 'adsd+dominik%40seam.cz+ssdasd'
          8        DO_FCALL                                      0          
   23     9        ASSIGN                                                   !1, '%2F%5E%28%2825%5B0-5%5D%7C2%5B0-4%5D%5Cd%7C%5B01%5D%3F%5Cd%3F%5Cd%29%5C.%29%7B3%7D%2825%5B0-5%5D%7C2%5B0-4%5D%5Cd%7C%5B01%5D%3F%5Cd%3F%5Cd%29%24%2F'
   25    10        ECHO                                                     'Test+IP%0A'
   26    11        INIT_FCALL                                               'testregexp'
         12        SEND_VAR                                                 !1
         13        SEND_VAL                                                 '10.1.0.1'
         14        DO_FCALL                                      0          
   27    15        INIT_FCALL                                               'testregexp'
         16        SEND_VAR                                                 !1
         17        SEND_VAL                                                 '199.1.0.1'
         18        DO_FCALL                                      0          
   28    19        INIT_FCALL                                               'testregexp'
         20        SEND_VAR                                                 !1
         21        SEND_VAL                                                 '255.1.0.1'
         22        DO_FCALL                                      0          
   29    23        INIT_FCALL                                               'testregexp'
         24        SEND_VAR                                                 !1
         25        SEND_VAL                                                 '256.1.0.1'
         26        DO_FCALL                                      0          
   30    27        INIT_FCALL                                               'testregexp'
         28        SEND_VAR                                                 !1
         29        SEND_VAL                                                 '260.1.0.1'
         30        DO_FCALL                                      0          
   31    31        INIT_FCALL                                               'testregexp'
         32        SEND_VAR                                                 !1
         33        SEND_VAL                                                 '300.1.0.1'
         34        DO_FCALL                                      0          
   32    35        INIT_FCALL                                               'testregexp'
         36        SEND_VAR                                                 !1
         37        SEND_VAL                                                 '1.0.1'
         38        DO_FCALL                                      0          
   33    39        INIT_FCALL                                               'testregexp'
         40        SEND_VAR                                                 !1
         41        SEND_VAL                                                 '125.1..1'
         42        DO_FCALL                                      0          
   34    43        INIT_FCALL                                               'testregexp'
         44        SEND_VAR                                                 !1
         45        SEND_VAL                                                 '192.11.168.255'
         46        DO_FCALL                                      0          
   35    47        INIT_FCALL                                               'testregexp'
         48        SEND_VAR                                                 !1
         49        SEND_VAL                                                 '192.11.168.256'
         50        DO_FCALL                                      0          
   36    51        INIT_FCALL                                               'testregexp'
         52        SEND_VAR                                                 !1
         53        SEND_VAL                                                 '192.11.168.300'
         54        DO_FCALL                                      0          
         55      > RETURN                                                   1

Function testregexp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 11
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AkNH4
function name:  testRegExp
number of ops:  16
compiled vars:  !0 = $regexp, !1 = $string, !2 = $valid
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        ASSIGN                                                   !2, $3
    5     7        CONCAT                                           ~5      !1, '+-+'
          8      > JMPZ                                                     !2, ->11
          9    >   QM_ASSIGN                                        ~6      'valid'
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~6      'invalid'
         12    >   CONCAT                                           ~7      ~5, ~6
         13        CONCAT                                           ~8      ~7, '%0A'
         14        ECHO                                                     ~8
    6    15      > RETURN                                                   null

End of function testregexp

Function matchregexp:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 12
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AkNH4
function name:  matchRegExp
number of ops:  16
compiled vars:  !0 = $regexp, !1 = $text, !2 = $matches
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !0
          4        SEND_VAR                                                 !1
          5        SEND_REF                                                 !2
          6        DO_ICALL                                         $3      
          7      > JMPZ                                                     $3, ->12
   11     8    >   INIT_FCALL                                               'print_r'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                                 
         11      > JMP                                                      ->14
   13    12    >   CONCAT                                           ~5      'no+match+in+text%3A+', !1
         13        ECHO                                                     ~5
   15    14    >   ECHO                                                     '%0A'
   16    15      > RETURN                                                   null

End of function matchregexp

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
175.33 ms | 1406 KiB | 30 Q