Re: StringCases kills Kernel
- To: mathgroup at smc.vnet.net
- Subject: [mg80876] Re: StringCases kills Kernel
- From: Mark Westwood <markc.westwood at gmail.com>
- Date: Tue, 4 Sep 2007 06:39:16 -0400 (EDT)
- References: <fb5nv5$8g8$1@smc.twtelecom.net><fb834d$7rj$1@smc.twtelecom.net>
Hi
I get the same behaviour as the OP, on a PC with 1GB RAM. I suspect
that there is a space issue in here, running the same operations with
the length of s equal to 10^1, 10^2, 10^3, 10^4 does not cause the
kernel to quit.
So I tried using Mathematica's 'native' StringExpressions, rewriting
the OP's second statement as:
StringCases[s,"0123456789"..]
with the same results -- OK up to a string length of 10^5 (or some
undetermined length between 10^4 and 10^5 to be more accurate), then
with a length of 10^5 the kernel quits.
At this point I could speculate about the internals of Mathematica,
but will forbear and get back to work ...
Regards
Mark Westwood
On Sep 3, 11:15 am, dh <d... at metrohm.ch> wrote:
> Hi Wim,
>
> please execute:
>
> s= StringJoin[Table["0123456789", {10^5}]];
>
> StringCases[s, RegularExpression["(0123456789)+"] ];
>
> or
>
> s= StringJoin[Table["0123456789", {10^5}]];
>
> StringCases[s, "0123456789" .. )];
>
> I then hear a beep, and clicking "Help/Why the Beep?" I am told that
>
> the kernel was killed.
>
> If this does not happen in your case, it may be that it depends on the
>
> RAM available. I have 1GB.
>
> Daniel
>
> dh wrote:
> > Hi Wim,
>
> > you have to execute both statements. The first one gives "s" a value.
>
> > Daniel
>
> > Wim W. Wilhelm wrote:
>
> >> Hi Daniel,
>
> >> I tried the example in version 6. The
>
> >> following warning was displayed:
>
> >> "String or list of strings expected at
>
> >> position 1 in \
>
> >> StringCases[s,RegularExpression[\!\(\"(0123456789)+\"\)]]"
>
> >> The Kernel wa's not killed.
>
> >> Wim W. Wilhelm
>
> >> "dh" <d... at metrohm.ch> wrote in message
>
> >>news:fb5nv5$8g8$1 at smc.twtelecom.net...
>
> >>> Hello,
>
> >>> I often read a file into a string and
>
> >>> use StringCases to extract
>
> >>> relevant information. However, if the
>
> >>> extracted part is too large, the
>
> >>> kernel is killed. This happens in
>
> >>> version 5 and 6. here is a simple
>
> >>> example:
>
> >>> s= StringJoin[Table["0123456789",
>
> >>> {10^5}]];
>
> >>> StringCases[s,
>
> >>> RegularExpression["(0123456789)+"] ];
>
> >>> the same also happens when we use a
>
> >>> StringPattern:
>
> >>> StringCases[s3, "0123456789" ..];
>
> >>> Daniel