Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2017 10:35
Show Gist options
  • Select an option

  • Save anonymous/34cfaea1cf71dcc5dc5224612b6d63ab to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/34cfaea1cf71dcc5dc5224612b6d63ab to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Oct 26, 2017.
    32 changes: 32 additions & 0 deletions regex.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    <?php
    $allow = array
    (
    '*.eitb.*',
    'tortolika'
    );

    $urls = array
    (
    'www.eitb.eus/asjdhjashdjahjkdhajkhdjk/',
    'http://www.eitb.eus/asjdhjashdjahjkdhajkhdjk/',
    'http://pre.eitb.eus/',
    'http://tortolika/',
    'tortolika/adasdasdass',
    'http://www.google.es',
    'www.google.es'
    );

    $z = array();
    foreach($urls as $url)
    {
    foreach($allow as $a)
    {
    $b = preg_replace("/\./", '\.', $a);
    $b = preg_replace("/\*/", '[^\s]+', $a);
    $b = "^(https?:\/\/|){$b}";
    if(preg_match("/$b/i", $url))
    $z[] = $url;
    }
    }

    print_r($z);