Skip to content

Instantly share code, notes, and snippets.

@mbparvezme
Last active January 16, 2020 14:30
Show Gist options
  • Save mbparvezme/430662efae1618de3ad59dd6d387ee82 to your computer and use it in GitHub Desktop.
Save mbparvezme/430662efae1618de3ad59dd6d387ee82 to your computer and use it in GitHub Desktop.
$testUsername = "https://twitter.com/webdevronsocial";
$regEx = '/(?:https?:\/\/)?(?:www\.)?twitter\.com\/(?:#!\/)?@?([a-zA-Z0-9_]{1,15})/';
if( preg_match( $regEx, $testUsername, $matches ) ){
/**
This is valid, play your code here
- $matches[0] will returns the profile URl
- $matches[1] will returns the Username
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment