Saturday, February 16, 2008

Book Review: Mastering Regular Expressions

I just finished the Jeffrey Friedl's Mastering Regular Expressions. My previous regexp education has been driven by the necessity to scan a log file or search or replace a snippet in a source tree -- that is, haphazard. Friedl's book really is worthy of its title and it should carry The Definitive Guide as its subtitle.

Friedl is a Regexp Master and reading this book is really an excellent way to improve your understanding of the theory, implementation, and application of regular expressions.

As a practical result of this book, I have noticed I am more confident in applying regexps in my text editors (UltraEdit and IntelliJ IDEA) for both search and replace -- particularly for "captured groups." This is useful for taking code and turning it into documentation that non-programmers can read.

Saturday, February 09, 2008

Create Fixed-Width Files Easily

If you need to create fixed-width files, you may be interested in a fixed-width recordset builder I wrote for Groovy. It lets you create a set of fixed-width records with the following sort of code:
def builder = new FixedWidthRecordSetBuilder()
builder.TestData(){
record1(){
field1(startPosition : 0, width : 5, content : short_content)
field2(startPosition : 5, width : 10, content : long_content)
}
record2(){
field1(startPosition : 0, width : 5, content : short_content.reverse())
field2(startPosition : 5, width : 10, content : long_content.reverse())
}
}

builder.records.each { record ->
println record.formattedContent //or to a file
}

You can get the goods from my svn repository:
You can log in with the user guest. The user does not have a password.

The Groovy website has more on the general topic of builders in Groovy.

Enjoy!

Tuesday, February 05, 2008

Grails 1.0 has been released

Grails 1.0 has been released! For details, see the release notes.

Grails is a convention-based web/enterprise application development framework that lets developers write in Groovy, but use all of the great existing Java infrastructure libraries like Spring and Hibernate.

I am using Groovy and Grails wherever I can and I love it -- I'm very productive. I also love that Grails 1.0 has a fix for the bug I encountered with 1.0-RC3.

Many thanks to Graeme Rocher and the Grails team.