MathGroup Archive 2000

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

Search the Archive

RE: working with large strings.


Dustin Soodak  wanted an efficient way to change some characters in a very
long string.

---------------------
Use the following:

In[1]:=
?StringReplacePart

StringReplacePart["string", "snew", {m, n}] replaces the characters at
positions m through n in "string" by "snew". StringReplacePart["string",
"snew", {{m1, n1}, {m2, n2}, ... }] inserts copies of "snew" at several
positions. StringReplacePart["string", {"snew1", "snew2", ... }, {{m1, n1},
{m2, n2}, ... }] replaces characters at positions mi through ni in "string"
by "snewi".


In the example below the 10th through 15th characters are replaced with
"xxxxxxxx".


In[2]:=
demo="abcdefghijklmnopqrstuvwxyz";
demo=StringReplacePart[demo,"xxxxxxxx",{10,15}]

Out[3]=
abcdefghixxxxxxxxpqrstuvwxyz


--------------------
Regards,
Ted Ersek

On 12-18-99 Mathematica tips, tricks at
http://www.dot.net.au/~elisha/ersek/Tricks.html
had a major update


  • Prev by Date: Re: Fast Fourier Transforms
  • Next by Date: Re: number types
  • Previous by thread: Re: working with large strings.
  • Next by thread: RE: working with large strings.