got stung lazily using a .* in a regular expression when I knew the real value

20 Aug

Was:

text = text.replace(new RegExp('<input id="'+elementID+'" class=".*" />'), '<input id="'+elementID+'" class="'+this.className+'" value="'+$(" />')
 
Now:

text = text.replace(new RegExp('<input id="'+elementID+'" class="'+this.className+'" />'), '<input id="'+elementID+'" class="'+this.className+'" value="'+$(" />')

Writing my first self-modifying web app is certaily forcing me to twist my mind to a new paradigm.

Advertisements

One Response to “got stung lazily using a .* in a regular expression when I knew the real value”

  1. Anonymous August 20, 2009 at 8:35 am #

    Even if you didn’t know the value, wouldn’t /".*?"/ have been safer than /".*"/?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: