3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $Test = "http://user:pass@www.example.com:8800/test/test.txt?query=1#fragment"; ################################################################################### # # pct-encoded := "%" HEXDIG HEXDIG # unreserved := ALPHA / DIGIT / "-" / "." / "_" / "~" # reserved := gen-delims / sub-delims # gen-delims := "#" / "/" / ":" / "?" / "@" / "[" / "]" # sub-delims := "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" # pchar := unreserved / pct-encoded / sub-delims / ":" / "@" $pct_encoded = '\x25[0-9A-Fa-f][0-9A-Fa-f]'; $unreserved = '[\x2d\x2e\x30-\x39\x41-\x5a\x5f\x61-\x7a\x7e\p{L}]'; $gen_dims = '[\x23\x2f\x3a\x3f]'; $sub_delims = '[\x21\x24\x26-\x2c\x3b\x3d\x40\x5b\x5d]'; $reserved = '[\x21\x23\x24\x26-\x2c\x2f\x3a\x3b\x3d\x3f\x40\x5b\x5d]'; $pchar = "[\\x21\\x24\\x26-\\x2e\\x30-\\x3b\\x3d\\x40-\\x5a\\x5f\\x61-\\x7a\\x7e\\p{L}]|$pct_encoded"; var_dump(preg_match("!$pct_encoded!", $Test)); var_dump(preg_match("!$unreserved!", $Test)); var_dump(preg_match("!$gen_dims!", $Test)); var_dump(preg_match("!$sub_delims!", $Test)); var_dump(preg_match("!$reserved!", $Test)); var_dump(preg_match("!$pchar!", $Test)); ################################################################################# # # segment := *pchar # segment-nz := 1*pchar # segment-nz-nc := 1*(unreserved / pct-encoded / sub-delims / "@") # ; non-zero-length segment without any colon ":" $segment = "(?:$pchar)*"; $segment_nz = "(?:$pchar)+"; $segment_nz_nc = "(?:$unreserved|$pct_encoded|$sub_delims|\\x40)+"; ################################################################################# # # path-abempty := *( "/" segment ) # path-absolute := "/" [ segment-nz *( "/" segment ) ] # path-noscheme := segment-nz-nc *( "/" segment ) # path-rootless := segment-nz *( "/" segment ) # path-empty := 0<pchar> $path_abempty = "(P<Path>(?:\\x2f$segment)*)"; $path_absolute = "(P<Path>\\x2f(?:$segment(?:\\x2f$segment)*)?)"; $path_noscheme = "(P<Path>$segment_nz_nc(?:\\x2f$segment)*)"; $path_rootless = "(P<Path>$segment_nz(?:\\x2f$segment)*)"; $path_empty = '(P<Path>)'; ################################################################################## # # IP-literal := "[" (IPv6address / IPvFuture) "]" # # IPvFuture := "v" 1*HEXDIG "." 1*(unreserved / sub-delims / ":") # # IPv6address := 6(h16 ":") ls32 # / "::" 5(h16 ":") ls32 # / [h16] "::" 4(h16 ":") ls32 # / [*1(h16 ":") h16] "::" 3(h16 ":") ls32 # / [*2( h16 ":") h16] "::" 2(h16 ":") ls32 # / [*3(h16 ":") h16] "::" h16 ":" ls32 # / [*4(h16 ":") h16] "::" ls32 # / [*5(h16 ":") h16] "::" h16 # / [*6(h16 ":") h16] "::" # # IPv4address := dec-octet "." dec-octet "." dec-octet "." dec-octet # # h16 := 1*4HEXDIG # ls32 := (h16 ":" h16) / IPv4address # dec-octet := DIGIT ; 0-9 # / %x31-39 DIGIT ; 10-99 # / "1" 2DIGIT ; 100-199 # / "2" %x30-34 DIGIT ; 200-249 # / "25" %x30-35 ; 250-255 $dec_octet = '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; $IPv4Address = "(P<IPv4Address>$dec_octet\\x2e$dec_octet\\x2e$dec_octet\\x2e$dec_octet)"; $h16 = '[0-9A-Fa-f]{1,4}'; $ls32 = "(?:$h16\\x3a$h16|$IPv4Address)"; $IPv6Address = "(P<IPv6Address>" . "(?:$h16\\x3a){6}$ls32|" . "\\x3a\\x3a(?:$h16\\x3a){5}$ls32|" . "(?:$h16)?\\x3a\\x3a(?:$h16\\x3a){5}$ls32|" . "(?:(?:$h16\\x3a){,1}$h16)?\\x3a\\x3a(?:$h16\\x3a){3}$ls32|" . "(?:(?:$h16\\x3a){,2}$h16)?\\x3a\\x3a(?:$h16\\x3a){2}$ls32|" . "(?:(?:$h16\\x3a){,3}$h16)?\\x3a\\x3a(?:$h16\\x3a){1}$ls32|" . "(?:(?:$h16\\x3a){,4}$h16)?\\x3a\\x3a$ls32|" . "(?:(?:$h16\\x3a){,5}$h16)?\\x3a\\x3a$h16|" . "(?:(?:$h16\\x3a){,6}$h16)?\\x3a\\x3a" . ")"; $IPvFuture = "v[0-9A-Fa-f]+\\x2e(?:$unreserved|$sub_delims|\\x3a)"; $IPvLiteral = "\\x5b(?:$IPv6Address|$IPvFuture)\\x5d"; ################################################################################ # # reg-name := *(unreserved / pct-encoded / sub-delims) $reg_name = "(?:$unreserved|$pct_encoded|$sub_delims)*"; ################################################################################ # # authority := [userinfo "@"] host [":" port] # userinfo := *(unreserved / pct-encoded / sub-delims / ":") # host := IP-literal / IPv4address / reg-name # port := *DIGIT $userinfo = "(P<Userinfo>(?:$unreserved|$pct_encoded|$sub_delims|\\x3a)*)"; $host = "(P<Host>$reg_name|$IPvLiteral|$IPv4Address)"; $port = "(P<Port>[0-9]*)"; $authority = "(?:$userinfo\\x40)?$host(?:\\x3a$port)?"; ################################################################################ # # scheme := ALPHA *(ALPHA / DIGIT / "+" / "-" / ".") # hier-part := "//" authority path-abempty # / path-absolute # / path-rootless # / path-empty # # relative-part := "//" authority path-abempty # / path-absolute # / path-rootless # / path-empty # query := *(pchar / "/" / "?") # fragment := *(pchar / "/" / "?") $scheme = '(P<Scheme>[A-Za-z][\x2b\x2d\x2e0-9A-Za-z]*)'; $hier_part = "(?:\\x2f\\x2f$authority$path_abempty|$path_absolute|$path_rootless|$path_empty)"; $relative_part = "(?:\\x2f\\x2f$authority$path_abempty|$path_absolute|$path_noscheme|$path_empty)"; $query = "(P<Query>(?:$pchar|\\x2f|\\x3f)*)"; $fragment = "(P<Fragment>(?:$pchar|\\x2f|\\x3f)*)"; ################################################################################ # # URI-reference := URI / relative-ref # # URI := scheme ":" hier-part ["?" query] ["#" fragment] # # relative-ref := relative-part ["?" query] ["#" fragment] $URI = "(?:$scheme\\x3a$hier_part(?:\\x3f$query)?(?:\\x23$fragment)?"; $relative_ref = "$relative_part(?:\\x3f$query)?(?:\\x23$fragment)?"; $URI_spec = "(P<URI>:$URI|$relative_ref)"; //print URI::getRegex();
Output for 4.4.0 - 4.4.9, 5.0.5, 5.1.1 - 7.1.0
int(0) int(1) int(1) int(1) int(1) int(1)
Output for 5.1.0
Fatal error: fatal flex scanner internal error--end of buffer missed in /in/hUPCU on line 153
Process exited with code 255.
Output for 4.3.11, 5.0.0 - 5.0.4
int(0) Warning: preg_match(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 45 in /in/hUPCU on line 23 bool(false) int(1) int(1) int(1) Warning: preg_match(): Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 58 in /in/hUPCU on line 27 bool(false)
Output for 4.3.0 - 4.3.10
int(0) Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 45 in /in/hUPCU on line 23 bool(false) int(1) int(1) int(1) Warning: Compilation failed: PCRE does not support \L, \l, \N, \P, \p, \U, \u, or \X at offset 58 in /in/hUPCU on line 27 bool(false)