Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Bug in Mathematica: regular expression applied to very
Posted:
Feb 14, 2010 8:17 AM
|
|
You can use the MAthematica string manipulation functions. Let me lengthen the string in an obvious way, by duplicating it 1000 times. s = "This is the first line. MAGIC_STRING Everything after this line should get removed. 12345678901234567890123456789012345678901234567890123456789012345678\ 901234567890 12345678901234567890123456789012345678901234567890123456789012345678\ 901234567890 12345678901234567890123456789012345678901234567890123456789012345678\ 901234567890 12345678901234567890123456789012345678901234567890123456789012345678\ 901234567890 12345678901234567890123456789012345678901234567890123456789012345678\ 901234567890 ...";
s = Nest[StringJoin[s, #] &, s, 1000];
StringLength[s]
492492
StringDrop[ StringReplace[ s, (p : Shortest[___ ~~ "\n" ~~ ___ ~~ "\n" ~~ ___ ~~ "\n"]) ~~ ___ :> p], -1]
so, processing only part of the string (using Shortest) gives the result in a fraction of a second
yehuda
On Sun, Feb 14, 2010 at 12:59 PM, dreeves <dreeves@gmail.com> wrote:
> I believe I found a bug in Mathematica's regular expression engine: > > http://stackoverflow.com/questions/2257884/bug-in-mathematica-reg > > I've submitted a bug report to support@wolfram but also wondering if > you all have thoughts on workarounds. > > Thanks! > > PS: Here's an rss feed of questions tagged mathematica on > stackoverflow: > http://stackoverflow.com/feeds/tag?tagnames=mathematica > >
|
|
|
|