MathGroup Archive 2000

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

Search the Archive

RE: working with large strings.

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21685] RE: [mg21615] working with large strings.
  • From: "Ersek, Ted R" <ErsekTR at navair.navy.mil>
  • Date: Sat, 22 Jan 2000 02:52:42 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

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: Integral of x/(1+x^4) problem (in Mathematica30)
  • Next by Date: RE: Intersection of 2 subspaces
  • Previous by thread: RE: working with large strings.
  • Next by thread: Header/Footer formatting question.