Re: Tricky regex question
- From: "Daniel Pitts" <googlegroupie@xxxxxxxxxxxxx>
- Date: 31 Jan 2007 11:32:31 -0800
On Jan 31, 11:29 am, Juan Singh <j...@xxxxxxxxxxxxx> wrote:
Daniel.
PERFECT! Thank you. This is exactly what I was looking for.
Juan.
Daniel Pitts wrote:
On Jan 31, 10:54 am, Juan Singh <j...@xxxxxxxxxxxxx> wrote:
Hi,
I need to split words from a sentence that are more than 2 letters. An
example sentence is:
This is "very" 'tricky'. I won't be able see it.
I came up with the following regex, but it breaks the word [won't] and I
only get the part that is before the single quote.
\b[a-zA-Z]{2,}+\b
My objective is to extract the following words from the example sentence
above.
This, very, tricky, won't, able
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());
}
}
}
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!
.
- References:
- Tricky regex question
- From: Juan Singh
- Re: Tricky regex question
- From: Daniel Pitts
- Re: Tricky regex question
- From: Juan Singh
- Tricky regex question
- Prev by Date: Re: Tricky regex question
- Next by Date: Re: best obfuscator
- Previous by thread: Re: Tricky regex question
- Next by thread: javamail and mbox
- Index(es):
Relevant Pages
|