Re: Re: substrings at the end of words
- To: mathgroup at smc.vnet.net
- Subject: [mg55063] Re: [mg55046] Re: substrings at the end of words
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Fri, 11 Mar 2005 04:20:37 -0500 (EST)
- References: <200503101025.FAA19390@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Well, it simply seems like your interpretation of the words:"I want to extract only the "ed" string which located only at the end of the words", (admittedly not perfectly clear) was and remains different from mine. After all, the OP did write "at the end of the words". And I can't see what makes you feel he wanted just one character before the "ed"? Andrzej On 10 Mar 2005, at 11:25, Bill Rowe wrote: > On 3/8/05 at 6:42 AM, akoz at mimuw.edu.pl (Andrzej Kozlowski) wrote: > > >> On 8 Mar 2005, at 11:03, fartous at mail15.com wrote: > >>> a = {"edit", "listed", "called", "wedding"} StringCases[a, _ ~~ >>> "ed"] Out[]= {{}, {ted}, {led}, {wed}} i want to extract only the >>> "ed" string which located only at the end of the words, i could >>> not do that using the above code. thanks jack > >> a = {"edit", "listed", "called", "wedding"}; >> StringCases[a,StringExpression[__,"ed",EndOfString]] > >> {{},{listed},{called},{}} > > This solution outputs the entire word instead of what the original > poster indicated and misses the case when the pattern isn't at the > end. The following outputs what the original poster requested > > a = {"edit", "listed", "called", "wedding"}; > StringCases[ > StringReplace[a, RegularExpression["([a-z]ed)[a-z]+"]->"$1"], > _~~"ed"~~EndOfString] > > {{}, {"ted"}, {"led"}, {"wed"}} > -- > To reply via email subtract one hundred and four > >
- References:
- Re: substrings at the end of words
- From: Bill Rowe <readnewsciv@earthlink.net>
- Re: substrings at the end of words