Useful Regular Expressions for Ruby

I intend to make this post a running tally of useful regex’s that I use, but for now I just have one.

This will extract a URL form a string. I’m using it to tinyurl URL’s in a twitter post that are posted from the Firebelly CMS.

/(http|https):\/\/([a-z0-9]+)[-.]?([a-z0-9]+).[a-z]{2,5}(([0-9]{1,5})?[\/\?][[\S]]?)?/ix

Post a Comment

Your email is never shared. Required fields are marked *

*
*