octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: behavior of regexp ( ) function


From: Søren Hauberg
Subject: Re: behavior of regexp ( ) function
Date: Wed, 28 Jan 2009 21:23:58 +0100

ons, 28 01 2009 kl. 21:20 +0100, skrev David Bateman:
> John W. Eaton wrote:
> > I'm not sure whether this is a bug.  But it is apparently incompatible
> > behavior.  I don't know what the fix is, but I looked at the
> > octregexp_list function, and it is correctly matching the first "20"
> > and moving idx forward to 2 (the position of the next character in the
> > string).  But then the next call to pcre_exec is matching zero or more
> > of anything not TAB and returning a zero-length substring starting and
> > ending at idx == 2.  So then ovector[1] <= ovector[0] and execution
> > breaks out of the loop.
> >   
> 
> I no longer have easy to matlab so can someone run the commands
> 
> a = sprintf("20\t50\tcelcius\t80");
> b = sprintf("20\t50\t\t80");
> regexp(a, '[^\t]+', 'match')
> regexp(b, '[^\t]+', 'match')
> regexp(a, '[^\t]*', 'match')
> regexp(b, '[^\t]*', 'match')
> 
> on matlab and send the results? Its not clear from your message John if 
> the behavior described by Daniel is the right  one.

>> a = sprintf('20\t50\tcelcius\t80');
>> b = sprintf('20\t50\t\t80');
>> regexp(a, '[^\t]+', 'match')

ans = 

    '20'    '50'    'celcius'    '80'

>> regexp(b, '[^\t]+', 'match')

ans = 

    '20'    '50'    '80'

>> regexp(a, '[^\t]*', 'match')

ans = 

    '20'    '50'    'celcius'    '80'

>> regexp(b, '[^\t]*', 'match')

ans = 

    '20'    '50'    '80'

Soren



reply via email to

[Prev in Thread] Current Thread [Next in Thread]