Archive for the ‘Regular Expressions’ Category

JavaScript’s Regular Expression exec/lastIndex bug?

Sunday, June 6th, 2010

There is a slight bug in how *certain* browsers handle JavaScript’s Regular Expression exec() method, and the two legends of Regular Expressions…

  1. Jan Goyvaerts (www.regexguru.com)
  2. Steven Levithan (blog.stevenlevithan.com)

…(both co-authors of the Regular Expressions Cookbook) seem to be in disagreement with each other as to how Internet Explorer implements this.

(more…)

Regular Expression to open external links in popup window

Tuesday, June 1st, 2010

This is a quick post to show you how to open up external website links within a pop-up window (without adding extra non semantic mark-up to your HTML code). In the past I’ve heard a lot of people talk about adding either custom attributes or using existing attributes such as rel as a hook for your JavaScript code to find links that should open in a pop-up window. I disagree, and suggest using Regular Expressions (regexes) along with some procedural code to help figure this out for you (it will save you the time and hassle of adding this extra mark-up yourself).

(more…)

Regular Expression Header Text Replacement

Thursday, May 27th, 2010

This is a post about some of my findings whilst trying to use Regular Expressions (Regex) to solve some problematic string issues. Along the way I learned something new about JavaScript’s text replacement methods that I didn’t know before and although it was very interesting to finally figure out, I was still slightly annoyed that it didn’t feature more prominently in more leading JavaScript books on the relevant sections of Regexes and text replacement using Regexes.

(more…)

Regular Expression Basics

Sunday, February 7th, 2010

Regular Expressions are a powerful utility within the JavaScript language. Essentially it allows you to search and manipulate strings of text with both simple and complex patterns.

(more…)