Created
August 26, 2016 22:56
-
-
Save Ravenstine/23d655c84495387aeeea3233c01524fb to your computer and use it in GitHub Desktop.
Did you know that you can name your match groups in a Regex?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"https://twitter.com/eh1030/status/12345/photo/1".match(/^(?<url>https?:\/\/twitter\.com\/[-a-zA-Z0-9+&@#%?=~_|!:,.;]+\/status(es){0,1}\/(?<tweetId>\d+)\/{0,1})/) | |
# => #<MatchData "https://twitter.com/eh1030/status/12345/" url:"https://twitter.com/eh1030/status/12345/" tweetId:"12345"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment