#regex
12 posts tagged regex. Clear filter
-
Select Basename in Postgres SQL
Postgres doesn't have a basename function per se. But it's easy to accomplish. select regexpreplace('http://www.seanbehan.com/images/logo.png', '.+/', '') ; -- Will return logo.png
-
How to Extract all Images from a Webpage with Ruby
Here is a little ruby snippet that will download all pictures from a webpage. Rather than using XPath, we are going to first reduce the source code to capture everything inside of quotes. Some...
-
How to Extract Time Information from a Natural Language String with a Regular Expression and PHP
You can easily extract time information from a string with a regular expression and PHP (or any language with regular expressions). $str = "Here is how to extract time info.. like 4:30 PM and 2:10...
-
Regex for Extracting URLs in Plain Text
Here is a Regex for extracting URLs from text. However, these links will not already be hyperlinked or source attribtues from images or iframes. This example is in PHP. I was trying to format a...
-
Matching email addresses in Javascript
Matching email addresses in Javascript regex = /\b[a-zA-Z0-9.%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b/img "hello sean@example.com how are you? do you know bob@example.com?".match(regex) // =...
-
How to Create a Slug in Python with the Re Module
There are a few 3rd party modules that do this sort of thing. But there is a pretty solution using out of the box Python functionality. You don't have to install any dependencies if you use the re...
-
A Ruby Regex for Removing Links and Images from Text
r = /https?:\/\/[\S]+/i youstring.gsub(r, '') Here's the rubular regex to play around with yourself http://rubular.com/r/SRKkYrW4IJ
-
Email Regex
Regular Expression that Matches Email Addresses:
-
Absolutize Relative Links Using PHP and Preg_Replace_Callback
I was in the market for a simple php script to replace hrefs with their absolute paths from scraped web pages. I wrote one myself. I used the preg\replace\callback function so that I could pass the...
-
Regular Expression for finding absolute URLs
Regular Expression for finding absolute URLs in a bunch of text... like a log file.
-
Email Obfuscation and Extraction from Text with Rails
There is a helper method for handling the obfuscation of email addresses in Rails. If you want to then extract an email address(or all email addresses) from a block of text here is the code. I...
-
Parse for Links with Prototype JS
Parsing for links with the Prototype javascript library is easy. Here is the pattern for finding links And to implement it you can loop through your containers that might contain links