MathGroup Archive 2005

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

Search the Archive

Re: position of letters in a string

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53834] Re: position of letters in a string
  • From: "Valeri Astanoff" <astanoff at yahoo.fr>
  • Date: Sat, 29 Jan 2005 06:02:42 -0500 (EST)
  • References: <ctcr1b$24v$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In[1]:=
f[str_String]:=
With[{ch = Characters[str]//.{a___,b_,c___,b_,d___} ->
{a,b,c,d}},{str,
MapIndexed[{#1,#2[[1]]}&,ch]}];

In[2]:=
f /@ {"catcatz","zrzttys"}

Out[2]=
{{catcatz,{{c,1},{a,2},{t,3},{z,4}}},{zrzttys,{{z,1},{r,2},{t,3},{y,4},{s,
5}}}}


  • Prev by Date: Re: Algebra of Einstein velocity addition
  • Next by Date: Cannot plot this functions
  • Previous by thread: Re: position of letters in a string
  • Next by thread: Re: position of letters in a string