Red Ronin wrote:
Is this fast enough? Other comments? Thankx in advance!
If performance satisfies you (or your customer) ..... then yes, it is fast enough.
In other case there are some improvements possible.
First, you don't need 6 different regex patterns to check this condition,
only one is sufficient:
Follow this link to study regex patterns, it's really cool:
http://www.regular-expressions.info/lookaround.html
Second, don't use regex at all,
simple 3 calls to a function String.contains() would be much more faster:
http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#contains%28java.lang.CharSequence%29
Third, the given problem is: "find the shortest string".
In your case, a "string" is equivalent to one line from the file.
So, if you have found a line that matches the condition, and the length of this line is X,
then you need to check only lines that have length < X.
For each new line check if it size is < X, if no - then just skip this line and take the next one.
If you find a new line shorter than X, that meet the condition too, then set X = length on this new line.
In this way you avoid searching substrings within the string probably for 50% or even more lines.