MathGroup Archive 2000

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

Search the Archive

Re: working with large strings.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21663] Re: [mg21615] working with large strings.
  • From: "David Park" <djmp at earthlink.net>
  • Date: Fri, 21 Jan 2000 04:00:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Dustin,

Have you tried this?

s1 = "This is the old string";

pos = StringPosition[s1, "old"]
{{13, 15}}

StringReplacePart[s1, "new", pos]
"This is the new string"

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

>
>If you want to write a program that alters elements of very large lists
>you can alter single elements with
>
>largelist[[elementnumber]]=newvalue;
>
>However, if you want to do this with a large string you have to do
>something like
>
>largestring=StringTake[largestring,{1,elementnumber-1}]<>newvalue<>StringTake[larges
tring,{1,elementnumber+1}];
>
>The problem with this is it requires making a whole new copy of the
>string to change just one element.  This will really slow a program down
>if you are working with large strings or have to repeat the process many
>times.
>
>Does anyone know a way around this?
>
>Dustin Soodak
>
>
>



  • Prev by Date: Re: working with large strings.
  • Next by Date: Re: a question about complex variable
  • Previous by thread: Re: working with large strings.
  • Next by thread: Re: working with large strings.