3v4l.org

run code in 300+ PHP versions simultaneously
<?php $abs = "Bob Rob Sue"; $abby = "sometext Bob1:2 is Sue3:4 where Rob2:1 etc"; // escape each word for safe use in a regular expression, then join with pipes $words = str_replace(" ", "|", preg_quote($abs)); // build a regular expression that finds a boundary, a word, \d+:\d+, and a boundary $regex = '/\b(' . $words . ')(\d+:\d+)\b/'; preg_match_all($regex, $abby, $matches, PREG_SET_ORDER); print_r($matches);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/NfoKu
function name:  (null)
number of ops:  24
compiled vars:  !0 = $abs, !1 = $abby, !2 = $words, !3 = $regex, !4 = $matches
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   3     0  E >   ASSIGN                                                   !0, 'Bob+Rob+Sue'
   4     1        ASSIGN                                                   !1, 'sometext+Bob1%3A2+is+Sue3%3A4+where+Rob2%3A1+etc'
   7     2        INIT_FCALL                                               'str_replace'
         3        SEND_VAL                                                 '+'
         4        SEND_VAL                                                 '%7C'
         5        INIT_FCALL                                               'preg_quote'
         6        SEND_VAR                                                 !0
         7        DO_ICALL                                         $7      
         8        SEND_VAR                                                 $7
         9        DO_ICALL                                         $8      
        10        ASSIGN                                                   !2, $8
  10    11        CONCAT                                           ~10     '%2F%5Cb%28', !2
        12        CONCAT                                           ~11     ~10, '%29%28%5Cd%2B%3A%5Cd%2B%29%5Cb%2F'
        13        ASSIGN                                                   !3, ~11
  12    14        INIT_FCALL                                               'preg_match_all'
        15        SEND_VAR                                                 !3
        16        SEND_VAR                                                 !1
        17        SEND_REF                                                 !4
        18        SEND_VAL                                                 2
        19        DO_ICALL                                                 
  13    20        INIT_FCALL                                               'print_r'
        21        SEND_VAR                                                 !4
        22        DO_ICALL                                                 
        23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
13.17 ms | 461 KiB | 7 Q