New Media Initiatives

Just another Walker Blogs weblog

Part of: blogs.walkerart.org

 
by Nate Solas at 3:42 pm 2006-12-06
Filed under:
3 Comments

Today I’ve got two good tools for web developers.

Lately I’ve had to write a number of regular expressions for the upcoming mnartists.org calendar – most in Java, and a few in Javascript. In theory a regexp is a regexp no matter the language, but in practice that’s rarely the case. Between these subtle differences and the maddening wait for compiling or reloading a page, it’s clear some sort of live testing environment is useful:

  • Javascript tester – allows replacement testing as well
  • Java tester – really nice in that it gives accurate feedback on your regexp errors and even helps you format the matching text as a java String

If you’re a developer messing with Java or Javascript regular expressions, IMHO it’s worth bookmarking those two pages.

Here’s a Java one – looks complicated, actually pretty straightforward. Anyone care to take a stab at what it does? :)

line = line.replaceAll(”\[([bi])\]([^\[]*)\[/\1\]“,”<$1>$2</$1>”);

(or can you do it better? I get by, but I know my regexps are sometimes clunky at best…)

 

3 Comments

  1. Sorry if you looked at this before this comment – I was having trouble getting WP to display the code line without messing it up. Looks good now, I think.

    Comment by Nate Schroeder — December 6, 2006 @ 3:52 pm

  2. Looks like it adds bold and italics around text (replacing non-html tags?).

    Comment by Brent Gustafson — December 6, 2006 @ 4:08 pm

  3. …close…

    Comment by Nate Schroeder — December 6, 2006 @ 4:11 pm

Sorry, the comment form is closed at this time.

Powered by WordPress