All posts in 'Java'

Today: Fun with Unicode, Regex and Java.

03-Nov-09

Some would say, i have 3 problems 😉 private final static Pattern placeholder = Pattern.compile("#\\{(\\w+?)\\}");private final static Pattern placeholder = Pattern.compile("#\\{(\\w+?)\\}"); won’t match “Mot#{ö}rhead” for example. To replace the word character \w you either need the list of possible unicodeblocks like [\p{InLatin}|\p{InEtc}] (you get the codes for the blocks through “Character.UnicodeBlock.forName” or you’re lazy like […]

Read the complete article »

Javas String.replaceAll

21-Jul-09

The following statement "foo baz".replaceAll("baz","$bar");"foo baz".replaceAll("baz","$bar"); will present you an java.lang.IllegalArgumentException: Illegal group reference exception as the replacement string can contain backreferences to the search pattern as stated in Mather#replaceAll: This method first resets this matcher. It then scans the input sequence looking for matches of the pattern. Characters that are not part of any […]

Read the complete article »

Grails, Hibernate, Current Session Context

12-Feb-09

Graeme was so kind to help me with this problem. My app worked well with Grails 1.0.4 but not in 1.1-beta3 any more. My first wild guess leading to a HibernateException: contains is not valid without active transactionHibernateException: contains is not valid without active transaction exception was my use of annotated Hibernate classes together with […]

Read the complete article »

Grails startup parameter

09-Feb-09

Just some snippets from the doku that I tend to forget: Run grails on a different port: grails -Dserver.port=9090 run-appgrails -Dserver.port=9090 run-app Run grails with a different environment: grails prod run-app // production grails -Dgrails.env=mycustomenv run-app // mycustomenvgrails prod run-app // production grails -Dgrails.env=mycustomenv run-app // mycustomenv

Read the complete article »