3v4l.org

run code in 300+ PHP versions simultaneously
<?php $re = '~(*UTF) x (?<!\w.) [\d._ –-]* (*SKIP) (*F) | order (?<!\worder) [\W_]* (?:number)? [\W_]* [\d._ –-]* (*SKIP) (*F) | (?<res>[1234578] (?>[._ –-]{0,3}\d){2} (?: 0{2} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){2} ) (?: 0{4} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){4} | (?<res>0 (?> 0{2} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){2} (?: 0{2} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){2}) (?: 0{4} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){4} | (?<res>6 (?> 66 [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){2} (?: 0{2} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){2}) (?: 0{4} [\d._ –-]* (*SKIP) (*F) )? (?>[._ –-]{0,3}\d){4} | 9 [\d._ –-]* (*SKIP) (*F)~ixJ'; $str = '//won\'t match if it is preceded with \'X\' or \'x\' x123456789 X123456789 x123-456-789 X123-456-789 123-456-789 ordernumber 123-456-789 order number123-456789 order number----123-456789 order number 123456789 ordernumber-x123456787 ordernumber-123456787 ORDERNUMBER-123456789 ordernumber - 123456789 ordernumber #123456789 ordernumber *%&%*123456789 ordernumber !@#$%^&123456789 order.number 123456789 order_number 123456789 order._.number 123456789 order...number#123456789 order-.-.-.-.123456789 order 123456789 order..123456789 order#123456789 order_#123456789 order._.#123456789 order___123456789 order#number 123456789 order......number 123456789 order.number.123456789 social security number 123-456-789 ordernumber !@#$%^&x123456789 123456789 #@%#$%#$123456789#$%#$^$# 123-456789 123456789 123456789 123 45 6789 123-45-6789 123-45-6789 123 – 45 – 6789 123.45.6789 123_45_6789 123 456 789 123-456-789 123 – 456 – 789 123.456.789 123_456_789 1234 56 789 1234-56-789 1234 – 56 – 789 1234.56.789 1234_56_789 12 345 6789 12-345-6789 12 – 345 – 6789 12.345.6789 12_345_6789 The number should not be matched at all for the following rules. If the number beginning with the number “9” 912345678 912000000 If the number “666” in positions 1 – 3. 666000000 666450000 666129876 If the number “000” in positions 1 – 3. 000000000 000450000 000120000 If the number “00” in positions 4 – 5. 123006789 876001234 765003456 if the number “0000” in positions 6 – 9 123450000 123000000 876000000 x123456789 X123456789 x123-456-789 X123-456-789 '; $n = 10000; $re2 = '/\b(?>x|order(?>[\W_]*number)?[\W_]*)\d+(*SKIP)(*F)|(?=(?>[._ –-]*\d){9})(?>(?>9|6{3}|0{3}|(?>\d\D*){3}00|(?>\d\D*){5}0{4})(*SKIP)(*F)|\d(?>\D*\d){4})/mi'; $start = microtime(true); for($i=0; $i<$n; $i++) { preg_match_all($re2, $str, $matches, PREG_SET_ORDER); } $time2 = microtime(true) - $start; $start = microtime(true); for($i=0; $i<$n; $i++) { preg_match_all($re, $str, $matches, PREG_SET_ORDER); } $time1 = microtime(true) - $start; $re3 = '/(\border\D*\W*)\d+(*SKIP)(*F)|(\border\D*number\W*)\d+(*SKIP)(*F)|(?<!x)(?=(?:[._ –-]*\d){9})(?!9|66\D*6|00\D*0|(?:\d\D*){3}0\D*0|(?:\d\D*){5}0(?:\D*0){3})\d(?:[._ –-]*\d){4}/mi'; $start = microtime(true); for($i=0; $i<$n; $i++) { preg_match_all($re3, $str, $matches, PREG_SET_ORDER); } $time3 = microtime(true) - $start; printf("Casimir: %.2e\nAnubhava: %.2e\nKamesh: %.2e", $time1, $time2, $time3);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 10
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 30
Branch analysis from position: 39
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 51
Branch analysis from position: 60
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 51
2 jumps found. (Code = 44) Position 1 = 60, Position 2 = 51
Branch analysis from position: 60
Branch analysis from position: 51
Branch analysis from position: 30
2 jumps found. (Code = 44) Position 1 = 39, Position 2 = 30
Branch analysis from position: 39
Branch analysis from position: 30
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 19, Position 2 = 10
Branch analysis from position: 19
Branch analysis from position: 10
filename:       /in/EDVGc
function name:  (null)
number of ops:  72
compiled vars:  !0 = $re, !1 = $str, !2 = $n, !3 = $re2, !4 = $start, !5 = $i, !6 = $matches, !7 = $time2, !8 = $time1, !9 = $re3, !10 = $time3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%7E%28%2AUTF%29%0A++x+%28%3F%3C%21%5Cw.%29+%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29%0A%7C%0A++order+%28%3F%3C%21%5Cworder%29+%5B%5CW_%5D%2A+%28%3F%3Anumber%29%3F+%5B%5CW_%5D%2A+%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29%0A%7C%0A++%28%3F%3Cres%3E%5B1234578%5D%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B2%7D%0A++%28%3F%3A+0%7B2%7D++%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B2%7D+%29%0A++%28%3F%3A+0%7B4%7D++%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B4%7D%0A%7C%0A++%28%3F%3Cres%3E0%0A++%28%3F%3E+0%7B2%7D++%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B2%7D%0A++%28%3F%3A+0%7B2%7D++%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B2%7D%29%0A++%28%3F%3A+0%7B4%7D++%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B4%7D%0A%7C%0A++%28%3F%3Cres%3E6%0A++%28%3F%3E+66+%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B2%7D%0A++%28%3F%3A+0%7B2%7D+%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B2%7D%29%0A++%28%3F%3A+0%7B4%7D+%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29+%29%3F%0A++%28%3F%3E%5B._+%E2%80%93-%5D%7B0%2C3%7D%5Cd%29%7B4%7D%0A%7C%0A++9+%5B%5Cd._+%E2%80%93-%5D%2A+%28%2ASKIP%29+%28%2AF%29%7EixJ'
   33     1        ASSIGN                                                   !1, '%2F%2Fwon%27t+match+if+it+is+preceded+with+%27X%27+or+%27x%27%0Ax123456789%0AX123456789%0Ax123-456-789%0AX123-456-789%0A123-456-789%0Aordernumber+123-456-789%0Aorder+number123-456789%0Aorder+number----123-456789%0Aorder+number+123456789%0Aordernumber-x123456787%0Aordernumber-123456787%0AORDERNUMBER-123456789%0Aordernumber+-+123456789%0Aordernumber+%23123456789%0Aordernumber+%2A%25%26%25%2A123456789%0Aordernumber+%21%40%23%24%25%5E%26123456789%0Aorder.number+123456789%0Aorder_number+123456789%0Aorder._.number+123456789%0Aorder...number%23123456789%0Aorder-.-.-.-.123456789%0Aorder+123456789%0Aorder..123456789%0Aorder%23123456789%0Aorder_%23123456789%0Aorder._.%23123456789%0Aorder___123456789%0Aorder%23number+123456789%0Aorder......number+123456789%0Aorder.number.123456789%0Asocial+security+number+123-456-789%0Aordernumber+%21%40%23%24%25%5E%26x123456789%0A123456789%0A%23%40%25%23%24%25%23%24123456789%23%24%25%23%24%5E%24%23%0A123-456789%0A123456789%0A123456789%0A123+45+6789%0A123-45-6789%0A123-45-6789%0A123+%E2%80%93+45+%E2%80%93+6789%0A123.45.6789%0A123_45_6789%0A123+456+789%0A123-456-789%0A123+%E2%80%93+456+%E2%80%93+789%0A123.456.789%0A123_456_789%0A1234+56+789%0A1234-56-789%0A1234+%E2%80%93+56+%E2%80%93+789%0A1234.56.789%0A1234_56_789%0A12+345+6789%0A12-345-6789%0A12+%E2%80%93+345+%E2%80%93+6789%0A12.345.6789%0A12_345_6789%0A%0AThe+number+should+not+be+matched+at+all+for+the+following+rules.%0A%0AIf+the+number+beginning+with+the+number+%E2%80%9C9%E2%80%9D%0A912345678%0A912000000%0A%0AIf+the+number+%E2%80%9C666%E2%80%9D+in+positions+1+%E2%80%93+3.%0A666000000%0A666450000%0A666129876%0A%0AIf+the+number+%E2%80%9C000%E2%80%9D+in+positions+1+%E2%80%93+3.%0A000000000%0A000450000%0A000120000%0A%0AIf+the+number+%E2%80%9C00%E2%80%9D+in+positions+4+%E2%80%93+5.%0A123006789%0A876001234%0A765003456%0A%0Aif+the+number+%E2%80%9C0000%E2%80%9D+in+positions+6+%E2%80%93+9%0A123450000%0A123000000%0A876000000%0A%0Ax123456789%0AX123456789%0Ax123-456-789%0AX123-456-789%0A'
  124     2        ASSIGN                                                   !2, 10000
  127     3        ASSIGN                                                   !3, '%2F%5Cb%28%3F%3Ex%7Corder%28%3F%3E%5B%5CW_%5D%2Anumber%29%3F%5B%5CW_%5D%2A%29%5Cd%2B%28%2ASKIP%29%28%2AF%29%7C%28%3F%3D%28%3F%3E%5B._+%E2%80%93-%5D%2A%5Cd%29%7B9%7D%29%28%3F%3E%28%3F%3E9%7C6%7B3%7D%7C0%7B3%7D%7C%28%3F%3E%5Cd%5CD%2A%29%7B3%7D00%7C%28%3F%3E%5Cd%5CD%2A%29%7B5%7D0%7B4%7D%29%28%2ASKIP%29%28%2AF%29%7C%5Cd%28%3F%3E%5CD%2A%5Cd%29%7B4%7D%29%2Fmi'
  129     4        INIT_FCALL                                               'microtime'
          5        SEND_VAL                                                 <true>
          6        DO_ICALL                                         $15     
          7        ASSIGN                                                   !4, $15
  130     8        ASSIGN                                                   !5, 0
          9      > JMP                                                      ->17
  132    10    >   INIT_FCALL                                               'preg_match_all'
         11        SEND_VAR                                                 !3
         12        SEND_VAR                                                 !1
         13        SEND_REF                                                 !6
         14        SEND_VAL                                                 2
         15        DO_ICALL                                                 
  130    16        PRE_INC                                                  !5
         17    >   IS_SMALLER                                               !5, !2
         18      > JMPNZ                                                    ~20, ->10
  134    19    >   INIT_FCALL                                               'microtime'
         20        SEND_VAL                                                 <true>
         21        DO_ICALL                                         $21     
         22        SUB                                              ~22     $21, !4
         23        ASSIGN                                                   !7, ~22
  136    24        INIT_FCALL                                               'microtime'
         25        SEND_VAL                                                 <true>
         26        DO_ICALL                                         $24     
         27        ASSIGN                                                   !4, $24
  137    28        ASSIGN                                                   !5, 0
         29      > JMP                                                      ->37
  138    30    >   INIT_FCALL                                               'preg_match_all'
         31        SEND_VAR                                                 !0
         32        SEND_VAR                                                 !1
         33        SEND_REF                                                 !6
         34        SEND_VAL                                                 2
         35        DO_ICALL                                                 
  137    36        PRE_INC                                                  !5
         37    >   IS_SMALLER                                               !5, !2
         38      > JMPNZ                                                    ~29, ->30
  140    39    >   INIT_FCALL                                               'microtime'
         40        SEND_VAL                                                 <true>
         41        DO_ICALL                                         $30     
         42        SUB                                              ~31     $30, !4
         43        ASSIGN                                                   !8, ~31
  142    44        ASSIGN                                                   !9, '%2F%28%5Cborder%5CD%2A%5CW%2A%29%5Cd%2B%28%2ASKIP%29%28%2AF%29%7C%28%5Cborder%5CD%2Anumber%5CW%2A%29%5Cd%2B%28%2ASKIP%29%28%2AF%29%7C%28%3F%3C%21x%29%28%3F%3D%28%3F%3A%5B._+%E2%80%93-%5D%2A%5Cd%29%7B9%7D%29%28%3F%219%7C66%5CD%2A6%7C00%5CD%2A0%7C%28%3F%3A%5Cd%5CD%2A%29%7B3%7D0%5CD%2A0%7C%28%3F%3A%5Cd%5CD%2A%29%7B5%7D0%28%3F%3A%5CD%2A0%29%7B3%7D%29%5Cd%28%3F%3A%5B._+%E2%80%93-%5D%2A%5Cd%29%7B4%7D%2Fmi'
  144    45        INIT_FCALL                                               'microtime'
         46        SEND_VAL                                                 <true>
         47        DO_ICALL                                         $34     
         48        ASSIGN                                                   !4, $34
  145    49        ASSIGN                                                   !5, 0
         50      > JMP                                                      ->58
  147    51    >   INIT_FCALL                                               'preg_match_all'
         52        SEND_VAR                                                 !9
         53        SEND_VAR                                                 !1
         54        SEND_REF                                                 !6
         55        SEND_VAL                                                 2
         56        DO_ICALL                                                 
  145    57        PRE_INC                                                  !5
         58    >   IS_SMALLER                                               !5, !2
         59      > JMPNZ                                                    ~39, ->51
  149    60    >   INIT_FCALL                                               'microtime'
         61        SEND_VAL                                                 <true>
         62        DO_ICALL                                         $40     
         63        SUB                                              ~41     $40, !4
         64        ASSIGN                                                   !10, ~41
  151    65        INIT_FCALL                                               'printf'
         66        SEND_VAL                                                 'Casimir%3A++%25.2e%0AAnubhava%3A+%25.2e%0AKamesh%3A+++%25.2e'
         67        SEND_VAR                                                 !8
         68        SEND_VAR                                                 !7
         69        SEND_VAR                                                 !10
         70        DO_ICALL                                                 
         71      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.8 ms | 1009 KiB | 16 Q