[Top][All Lists]

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

Re: Specific fixed width question...

From: CdeMills
Subject: Re: Specific fixed width question...
Date: Thu, 16 Sep 2010 07:12:15 -0700 (PDT)

Sergei Steshenko-2 wrote:
> Again, Octave uses PCRE, which means Perl-Compatible Regular Expressions.
> AFAIK, Perl regular expressions engine is much more capable than what
> POSIX mandates.
> I do not know which limitations Octave imposes on PCRE.
None, indeed. We have to pre-process the string first, to remove potentially
unexpected digits, and proceed further on the result:

str2num(regexprep('WA 053 011 Clark County 123            45 ',
'\D{1,3}(\d+) (\d+).{1,30} (\d+)', '$1 $2 $3'))

ans =

   53   11   45

With this approach, we skip the initial non-digits, choose two digits
strings separated by one space, then skip up to 30 chars, then look at one
digit string. Finally, we concatenate the three strings.
It skips the "123" because the engine is greedy, i.e. it looks at the
longuest match. 



View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

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