Skip to content

Instantly share code, notes, and snippets.

@jakebathman
Created August 31, 2015 17:53
Show Gist options
  • Save jakebathman/6573cd15f4213a282ab6 to your computer and use it in GitHub Desktop.
Save jakebathman/6573cd15f4213a282ab6 to your computer and use it in GitHub Desktop.
TryBot regex
<?php
$arrRegexPatterns = array(
'subreddit' => "/(reddit\.com|reddittryhard\.com)?(?:\/r\/){1}([\w]+)/i",
);
if (preg_match($arrRegexPatterns['subreddit'], $text, $arrMatches) !== false)
{
echo json_encode($arrMatches);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment