sofac / rfc-3986
Working with URIs/URLs following Standard 3986
v1.0.0
2026-04-11 01:21 UTC
Requires
- php: >=8.4
README
Require
_ PHP 8.4 or higher
Using
use Sofac\Standards\Rfc3986\Character; use Sofac\Standards\Rfc3986\Enums\DelimiterRegex; /* SOME USEFUL CONSTANTS */ $genDelims = Character::GEN_DELIMS; $subDelims = Character::SUB_DELIMS; echo "<pre>"; print_r($genDelims); echo "</pre>"; /* result $subDelims Array ( [0] => : [1] => / [2] => ? [3] => # [4] => [ [5] => ] [6] => @ ) */ /* METHODS */ /* Returns already escaped sub-delims for use in regex. */ $sub = Character::subDelimsForRegex(); // '\!\$&'\(\)\*\+,;\=' /* Returns already escaped sub-delims for use in regex. except */ $subExcept = Character::subDelimsForRegex(')','=');// '\!\$&'\(\*\+,;' /* Regex builder, still under development. */ $regex = Character::makerRegex( DelimiterRegex::SLASH_DELIMITER, '(?:[^', Character::unreservedForRegex(), Character::subDelimsForRegex(), Character::gemDelimsForRegex("#", "[", "]"), '%]++|', Character::percentIdentifyRegex(), ')' ); echo $regex; /* result: '/(?:[^A-Za-za-z0-9\-\._~\!\$&'\(\)\*\+,;\=\:\/\?@%]++|%(?![A-Fa-f0-9]{2}))/' */