"instead of using a regex, you could simply iterate over the characters ..."
That is what I would do. I would string together a few org.apache.commons.lang.StringUtils calls into a method; then write a few unit tests and call it a day. Someone could come along later and rewrite my method using "magic" regular expressions, but as the previous commenter pointed out, that probably wouldn't save you anything. But as long as the unit tests work, it's all good.
Ross
To: seajug-***@public.gmane.org
From: seajug-***@public.gmane.org
Date: Fri, 13 Jun 2014 15:47:35 -0700
Subject: Re: [seajug] extracting class name from String
Because the problem is a greedy search from the start of the string,
and because the start character is unique and the subsequent stop
character is also without need of further search after finding,
instead of using a regex, you could simply iterate over the characters
in the log statement from character at index 0 to the first ':',then begin storing characters or note startIndex,and continue to the subsequent '.' afterwards to stop storing charactersor note stopIndex.If the log statement is already stored in a String or CharBuffer, youcan use charAt to extract each character without creating new objects.The comparison can use the characters integer ascii values and the equals operator (comparison is to ':' or '.').
For your specific problem, that should be far fewer steps than using Pattern and Matcher with a regular expression.