Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: substrings at the end of words

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55046] Re: substrings at the end of words
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Thu, 10 Mar 2005 05:25:09 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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


  • Prev by Date: Re: RationalApproximation
  • Next by Date: Re: symbolic approximation (formular manipulation)
  • Previous by thread: Re: substrings at the end of words
  • Next by thread: Re: Re: substrings at the end of words