RegEx to get the Root Domain from a String of HTML

Extracting URL’s from a string of HTML text using the php preg_match_all() function can grab you an array of the full URLs or an array of just the root domains depending on the RegEx used. I’ll provide a premade function snippet that you can use for both. The only difference between these two functions is […]

RegEx to Find a Word within a String Using preg_match

When using preg_match to find a word in a string, you’ll find that the default regex usedĀ in most examplesĀ  (ex: “/needle/i” ) works perfectly fine for finding if a pattern occurs in the string, but if you are looking to find a specific word it can get you unexpected results. For example, if we want […]