ippey/url-regex

Regular expression for matching URLs

dev-master 2017-06-28 01:15 UTC

This package is auto-updated.

Last update: 2024-11-20 20:17:24 UTC


README

Regular expression for matching URLs

Based on this gist by Diego Perini.

Install

composer require ippey/url-regex

Usage

<?php
require_once('vendor/autoload.php');

use Ippey\UrlRegex;

// true
$result = Ippey\UrlRegex::isMatch('This contains URL. http://www.google.com');

// false
$result = Ippey\UrlRegex::isMatch('This contains no URL.');

// array('http://www.google.com')
$result = Ippey\UrlRegex::match('This contains URL. http://www.google.com');

// array()
$result = Ippey\UrlRegex::match('This contains no URL.');

// array('https://www.google.co.jp/?q=github', 'https://www.github.com')
$result = Ippey\UrlRegex::match('This contains URL. https://www.google.co.jp/?q=github and https://www.github.com');

Copyright

Ippei Sumida

License

MIT