Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Bug in Mathematica: regular expression applied to very
Replies: 1   Last Post: Feb 14, 2010 8:17 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
yehuda ben-shimol

Posts: 302
Registered: 2/11/05
Re: Bug in Mathematica: regular expression applied to very
Posted: Feb 14, 2010 8:17 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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
>
>






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.