Tag Archives: RegEx

How-to Extract All The URLs From a String

I was helping out in a forum discussion in which a developer was asking for assistance in getting a listing of URLs found within a string of text and thought I’d share here the solution(s) I came up with as I’m sure he’s not the first, nor the last to need to do this type of thing.
 
Continue reading

VBA – Using Regular Expressions (RegEx)

One of the most powerful features of many other programming languages is their ability to utilize Regular Expressions (RegEx) for finding patterns… to manipulate and/or extract data from strings.

Sadly however, VBA does not have the ability to use them, well at least not natively! Thankfully, it really is not very complicated to be able to integrate RegEx into one any VBA procedure by simply creating a VBScript object (since VBScript does support RegEx).

The basic idea goes something like:

Set oRegEx = CreateObject("VBScript.RegExp")
oRegEx.Pattern = "YourRegEx Goes Here"
bResult = oRegEx.Test(YourStringToTestTheRegExWith)

Instead of just testing, you can .Execute, .Replace… Lots of fun things you can do with RegEx.

Continue reading