3v4l.org

run code in 300+ PHP versions simultaneously
<?php $grid_id_unique_name = 'vc_gid'; $pattern = getShortcodeRegexForId(); var_dump($pattern[10]); $content = '[hello]'; preg_match_all( "/$pattern/", $content, $found ); function getShortcodeRegexForId() { return '\\[' // Opening bracket . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]] . '([\\w-_]+)' // 2: Shortcode name . '(?![\\w-])' // Not followed by word character or hyphen . '(' // 3: Unroll the loop: Inside the opening shortcode tag . '[^\\]\\/]*' // Not a closing bracket or forward slash . '(?:' . '\\/(?!\\])' // A forward slash not followed by a closing bracket . '[^\\]\\/]*' // Not a closing bracket or forward slash . ')*?' . '(?:' . '(' . 'vic_gid' // 4: GridId must exist . '[^\\]\\/]*' // Not a closing bracket or forward slash . ')+' . ')' . ')' . '(?:' . '(\\/)' // 5: Self closing tag ... . '\\]' // ... and closing bracket . '|' . '\\]' // Closing bracket . '(?:' . '(' // 6: Unroll the loop: Optionally, anything between the opening and closing shortcode tags . '[^\\[]*+' // Not an opening bracket . '(?:' . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag . '[^\\[]*+' // Not an opening bracket . ')*+' . ')' . '\\[\\/\\2\\]' // Closing shortcode tag . ')?' . ')' . '(\\]?)'; // 7: Optional second closing brocket for escaping shortcodes: [[tag]] }
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
string(1) "w" Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 11 in /in/fRGb0 on line 7
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 string(1) "w" Warning: preg_match_all(): Compilation failed: invalid range in character class at offset 11 in /in/fRGb0 on line 7
Output for 7.2.0 - 7.2.34
string(1) "w"

preferences:
161.18 ms | 401 KiB | 183 Q