Skip to content

Instantly share code, notes, and snippets.

@kpobococ
kpobococ / function.rfc3986_validate_uri.php
Last active July 27, 2021 13:13
Regular Expression to validate URI (RFC 3986 http://tools.ietf.org/html/rfc3986)
<?php
function rfc3986_validate_uri($uri)
{
// Play around with this regexp online:
// http://regex101.com/r/hZ5gU9/1
// Links to relevant RFC documents:
// RFC 3986: http://tools.ietf.org/html/rfc3986 (URI scheme)
// RFC 2234: http://tools.ietf.org/html/rfc2234#section-6.1 (ABNF notation)