> Hi,
>
[quoted text clipped - 12 lines]
>
> This, very, tricky, won't, able
I'd split the string on whitespace (to get {This, is, "very", 'tricky'.,
I, won't, be, able, see, it.}) and then write a function which acts like
trim(), but rather than removing leading or trailing whitespace, it removes
leading or trailing punctuation. That'll give {This, is, very, tricky, I,
won't, be, able, see, it} which you can then walk through and eliminate all
2 char characters or less.
- Oliver
Daniel Pitts - 31 Jan 2007 19:17 GMT
> > Hi,
>
[quoted text clipped - 21 lines]
>
> - Oliver
I was going to suggest this, then I realize that there IS a regex that
can do it.
\w+('?\w){2,}
I even posted an SSCCE to show how it works.
> Hi,
>
[quoted text clipped - 14 lines]
>
> Thanks.
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Test {
public static void main(String[] args) {
Pattern longword = Pattern.compile("\\w+('?\\w){2,}");
String input = "This is \"very\" 'tricky'. I won't be able see
it.";
Matcher matcher = longword.matcher(input);
while (matcher.find()) {
System.out.println(matcher.group());
}
}
}
Juan Singh - 31 Jan 2007 19:29 GMT
Daniel.
PERFECT! Thank you. This is exactly what I was looking for.
Juan.
>> Hi,
>>
[quoted text clipped - 28 lines]
> }
> }
Daniel Pitts - 31 Jan 2007 19:32 GMT
> Daniel.
>
[quoted text clipped - 34 lines]
> > }
> > }
As Andrew Thompson says:
"Future lack of top-posting will be thanks enough".
On this group, we reply AFTER the quote or mixed-in with the quote!