Re: Tricky regex question
- From: "Daniel Pitts" <googlegroupie@xxxxxxxxxxxxx>
- Date: 31 Jan 2007 11:17:05 -0800
On Jan 31, 11:08 am, "Oliver Wong" <o...@xxxxxxxxxxxxxx> wrote:
"Juan Singh" <j...@xxxxxxxxxxxxx> wrote in messageI was going to suggest this, then I realize that there IS a regex that
news:6aednfAhprlueF3YnZ2dnUVZ_uHinZ2d@xxxxxxxxxxxxxx
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
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
can do it.
\w+('?\w){2,}
I even posted an SSCCE to show how it works.
.
- References:
- Tricky regex question
- From: Juan Singh
- Re: Tricky regex question
- From: Oliver Wong
- Tricky regex question
- Prev by Date: Re: Tricky regex question
- Next by Date: Re: javamail and mbox
- Previous by thread: Re: Tricky regex question
- Next by thread: Re: Tricky regex question
- Index(es):