3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Mauris commodo quis imperdiet massa. Turpis egestas pretium aenean pharetra. In hac habitasse platea dictumst ves33tibulum rhoncus est pellentesque. Purus faucibus ornare suspendisse sed nisi lacus. Malesuada bibendum arcu vitae elementum curabitur vitae nunc sed velit. Aliquam ultrices sagittis orci a scelerisque. Lorem123 ipsum dolor sit amet consectetur adipiscing. Tristique senectus et netus et malesuada fames ac. Eget duis at tellus at urna. Auctor eu augue ut lectus arcu bibendum at. In ante metus dictum at tempor com444modo ullamcorper a. Dolor magna eget est lorem ipsum. Lorem dolor sed viverra ipsum nunc aliqu666et bibendum. Urna duis convallis convallis tellus id."; $pattern = # Word before a comma # -- Positive look ahead assertion '%\w+(?=,)' # All Characters inbetween up to the next comma # -- Negative look after assertion .'.*(?<=,)%'; preg_match($pattern, $string, $match); var_dump($match); $pattern = # Get all words that contain the letter p and are just before a full stop. '%(\w+p\w+)(?=\.)%'; ; # Match will contain a subgroup match, notice the extra returned value in array. preg_match($pattern, $string, $match); var_dump($match); #### Flags # PREG_OFFSET_CAPTURE # -- Return the offset from each result given in match - integer for location in string preg_match($pattern, $string, $match, PREG_OFFSET_CAPTURE); var_dump($match); $pattern = # Find the first mixed number and letter word. # Remove unfound subpatterns with null with optional flag '%\w+\d+(999)*\w+%'; # PREG_UNMATCHED_AS_NULL preg_match($pattern, $string, $match, PREG_UNMATCHED_AS_NULL); var_dump($match); # Offset - Assertions can make results differ preg_match($pattern, $string, $match, PREG_OFFSET_CAPTURE, 250); var_dump($match);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Y0JWg
function name:  (null)
number of ops:  49
compiled vars:  !0 = $string, !1 = $pattern, !2 = $match
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Lorem+ipsum+dolor+sit+amet%2C+consectetur+adipiscing+elit%2C+sed+do+eiusmod+tempor+incididunt+ut+labore+et+dolore+magna+aliqua.+Mauris+commodo+quis+imperdiet+massa.+Turpis+egestas+pretium+aenean+pharetra.+In+hac+habitasse+platea+dictumst+ves33tibulum+rhoncus+est+pellentesque.+Purus+faucibus+ornare+suspendisse+sed+nisi+lacus.+Malesuada+bibendum+arcu+vitae+elementum+curabitur+vitae+nunc+sed+velit.+Aliquam+ultrices+sagittis+orci+a+scelerisque.+Lorem123+ipsum+dolor+sit+amet+consectetur+adipiscing.+Tristique+senectus+et+netus+et+malesuada+fames+ac.+Eget+duis+at+tellus+at+urna.+Auctor+eu+augue+ut+lectus+arcu+bibendum+at.+In+ante+metus+dictum+at+tempor+com444modo+ullamcorper+a.+Dolor+magna+eget+est+lorem+ipsum.+Lorem+dolor+sed+viverra+ipsum+nunc+aliqu666et+bibendum.+Urna+duis+convallis+convallis+tellus+id.'
    6     1        ASSIGN                                                   !1, '%25%5Cw%2B%28%3F%3D%2C%29.%2A%28%3F%3C%3D%2C%29%25'
   13     2        INIT_FCALL                                               'preg_match'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        SEND_REF                                                 !2
          6        DO_ICALL                                                 
   14     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   17    10        ASSIGN                                                   !1, '%25%28%5Cw%2Bp%5Cw%2B%29%28%3F%3D%5C.%29%25'
   22    11        INIT_FCALL                                               'preg_match'
         12        SEND_VAR                                                 !1
         13        SEND_VAR                                                 !0
         14        SEND_REF                                                 !2
         15        DO_ICALL                                                 
   23    16        INIT_FCALL                                               'var_dump'
         17        SEND_VAR                                                 !2
         18        DO_ICALL                                                 
   29    19        INIT_FCALL                                               'preg_match'
         20        SEND_VAR                                                 !1
         21        SEND_VAR                                                 !0
         22        SEND_REF                                                 !2
         23        SEND_VAL                                                 256
         24        DO_ICALL                                                 
   30    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                                 
   32    28        ASSIGN                                                   !1, '%25%5Cw%2B%5Cd%2B%28999%29%2A%5Cw%2B%25'
   37    29        INIT_FCALL                                               'preg_match'
         30        SEND_VAR                                                 !1
         31        SEND_VAR                                                 !0
         32        SEND_REF                                                 !2
         33        SEND_VAL                                                 512
         34        DO_ICALL                                                 
   38    35        INIT_FCALL                                               'var_dump'
         36        SEND_VAR                                                 !2
         37        DO_ICALL                                                 
   42    38        INIT_FCALL                                               'preg_match'
         39        SEND_VAR                                                 !1
         40        SEND_VAR                                                 !0
         41        SEND_REF                                                 !2
         42        SEND_VAL                                                 256
         43        SEND_VAL                                                 250
         44        DO_ICALL                                                 
   43    45        INIT_FCALL                                               'var_dump'
         46        SEND_VAR                                                 !2
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.14 ms | 1443 KiB | 15 Q