Re: Tricky regex question




"Juan Singh" <js@xxxxxxxxxxxxx> wrote in message
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


.



Relevant Pages

  • Tricky regex question
    ... I need to split words from a sentence that are more than 2 letters. ... This is "very" 'tricky'. ... My objective is to extract the following words from the example sentence above. ...
    (comp.lang.java.programmer)
  • Re: word count - letter count (newbie)
    ... > I'm trying to use 'wc' to count some letters in a tricky way. ... A Problem-Solution Approach, 2005, Apress ...
    (comp.unix.misc)
  • Re: Tricky regex question
    ... I need to split words from a sentence that are more than 2 letters. ... This is "very" 'tricky'. ... Matcher matcher = longword.matcher; ...
    (comp.lang.java.programmer)
  • Re: Blank Posts
    ... Leashes are tricky little SOBS, ... http://www.cat-sidh.net (the Mother Ship) ... http://esther.cat-sidh.net (Letters to Esther) ...
    (rec.pets.dogs.behavior)
  • Re: Italy -question about law banning kettles in hotel bedrooms
    ... >>Those tricky double letters! ... >If you're gonna correct my typos, I'm gonna reciprocate. ...
    (rec.travel.europe)