MetaChat REGISTER   ||   LOGIN   ||   IMAGES ARE OFF   ||   RECENT COMMENTS




artphoto by splunge
artphoto by TheophileEscargot
artphoto by Kronos_to_Earth
artphoto by ethylene

Home

About

Search

Archives

Mecha Wiki

Metachat Eye

Emcee

IRC Channels

IRC FAQ


 RSS


Comment Feed:

RSS

08 April 2009

Does anyone here know regexp? [More:]
I want to find instances when the letter Y appears in a non-consecutive manner.

examples:

NNNYNNYYYNN
NNYNYNNNNNN
and so on.

I have never done regexp before and am having a hard time figuring out a formula.

What I want is something like *Y*Y* (although this is not completely right)

There can be zero or more characters before the first Y.
The * between the Ys should match at least one character that is not a Y.
And there can be 0 or more characters after the last Y.

help?
How about: Y[^Y][^Y]*Y
You don't care what comes before the first Y or after the second Y.
You could also say Y[^Y]+Y if you are using extended regular expressions.
Note that I'm using unix regex, not the perl or windows variety.
posted by DarkForest 08 April | 18:53
Thanks Darkforest. That worked beautifully. I owe you one.

posted by special-k 08 April | 19:00
Looking for a nice writing pad-folio. || An AskMe post gave me a place to live; a Tweet took it away.

HOME  ||   REGISTER  ||   LOGIN