by kindom_2006 » Thu Jul 23, 2009 4:43 am
Ok, this is really not enough info to answer the question fully, but ...
let's assume your word is "apple"
to match "apple" you need /apple/
simple.
let assume you have a second word, "orange"
then /(apple|orange)/
Note that with regex syntax, maybe slightly different depending on what language you're using
Ok, now regards capture this fully depends on what language you're using. It's pretty much completely different in every programming language. But often the captured expression string is referred to by \1 or $1
anyway ... continuing on alternate endings:
Lets say you want to find the endings: "green" "sweet" or "seeds".
Then perhaps you could use:
/((apple|orange) (green|sweet|seeds))/
by using separate parenthesis sets, \1 or $1 will be the entire phrase, \2 or $2 will be apple or orange, and \3 or $3 will hold the final part, green, sweet or seeds.
If you want to captures "anything" between your start and your end, then maybe :
/((apple|orange)(.*)(green|sweet|seeds))/
will be what you want, in this case matches 1 and 2 are like the above, and 3 is your "anything" 4 is the terminus, green/sweet/seeds.
I think that's all I can answer,
hth