Yup! There’s a new blog engine in town boys!

I was getting tired of cleaning up comment spam (aren’t we all) and was looking around for a replacement writeback plugin for Blosoxom that had spam blocking. Well one thing led to another (as the internet is want to do) and I ended up reading a bunch of really nice things about WordPress.

So, I took the plunge and after a little futzing with the templates and css I’m back in business. The comments didn’t make it through (I think they might have fallen down a crevasse), but well, most of them were spam anyway :-). (Q: Should punctuation go before or after a smiley?) If you’d posted any, and were really attached to them, let me know. I’ll go all St. Bernard on them and haul them up.

So without further ado, I’d like to introduce the new reBeLog, now with added blogging power, searching, a calendar, and a fresh new minty taste!

Practical WebObjects

A new WebObjects book by Charles (Chuck) Hill and Sacha Mallais arrived on my doorstep last week (literaly, Steve accidentally ordered two copies, and I benefited from his Amazon click happiness). Practical WebObjects is aimed at intermediate WebObjects developers and I think it succeeds nicely. From talking about integrating Unit testing and contract programming to examples of Kerberos authentication it offers plenty of practical examples and lots of stuff to think about.

Not having taken the WebObjects courses offered by Apple (and others), I’ve done the majority of my learning relying on books, the web, the docs, and playing. Practical WebObjects is a solid book that adds depth to the existing offerings. I wouldn’t suggest it as a first book to someone getting started (Joshua Markers Visual Quick Pro Guide and Apple’s Tutorial are a better bet there) but for someone who is looking to expand their horizons or for a best practices guide I think it does an admirable job.

Thanks Chuck and Sacha!

Java 1.4 regex fun

I’m sure that everyone knows that Java 1.4 added regex capabilities through the java.util.regex package. I have existing applications using regex (from Jakarta Oro) that were built pre Java 1.4 so I haven’t looked at this support closely until now.

What I hadn’t realized was that you don’t need to use the Pattern or Matcher classes in java.util.regex to do simple regex substitutions, that capability is built right into java.lang.string!

An example of this usage would be formating phone numbers for storage or display. I usually like to store phone numbers as 10 character strings, and apply formating when they are displayed. This is easy using regex substitution. To format for storage:

String source = "(555) 555-5555";
String result = source.replaceAll("^1|\\D+", "");

The result will be "5555555555".

Conversely, to format for display:

String source = "5555555555;
String result = source.replaceAll("^(\\d{3})(\\d{3})(\\d{4})", 
				  "($1) $2-$3");

The result will be "(555) 555-5555".

The documentation for String.replaceAll is here and it is fairly straight forward:

public String replaceAll(String regex,
                         String replacement)

The first example used the regex: "^1|\\D+"  It says; match the first character if it is a "1" (^1) OR (|) any character that is not a number (\\D+) and replace with "" (the replacement).

The second example used the regex: "^(\\d{3})(\\d{3})(\\d{4})"  It says; match the first 3 characters and put them into a variable ($1) do the same for the next 3 ($2) and the final 4 ($3). Then using the replacement: "($1) $2-$3" wrap the contents of $1 with "()" add a space and the contents of $2, followed by a "-" and the contents of $3.

A good regex primer can be found here