help-octave
[Top][All Lists]
Advanced

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

Re: Specific fixed width question...


From: Sergei Steshenko
Subject: Re: Specific fixed width question...
Date: Thu, 16 Sep 2010 04:51:52 -0700 (PDT)


--- On Thu, 9/16/10, CdeMills <address@hidden> wrote:

> From: CdeMills <address@hidden>
> Subject: Re: Specific fixed width question...
> To: address@hidden
> Date: Thursday, September 16, 2010, 4:01 AM
> 
> 
> Sergei Steshenko-2 wrote:
> > 
> > 
> >> From: John W. Eaton <address@hidden>
> >> Subject: Re: Specific fixed width question...
> >> To: "CdeMills" <address@hidden>
> >> Cc: address@hidden
> > [snip]
> >> Is there a good way to write the above
> >> using a regexp that
> >> will only match the data in columns 4-6, 8-10, and
> 37-39?
> >> 
> >> jwe
> > 
> > 
> > Well, in Perl (and, I guess, in PCRE used by Octave)
> '.' matches any
> > character, so, say, the following
> > 
> > $s =~ m/^.{3}(.{4}).{5}(.{6})/;
> > #             
> $1        $2
> > 
> > skips 3 character from the beginning, then matches 4
> characters and puts
> > them into $1, then skips 5 characters and then matches
> 6 characters and
> > puts them into $2.
> > 
> > 
> 
> We have reached here a limitation of regexpes, that is, the
> inability to
> specify what to return and what to not return. According to
> 
> https://secure.wikimedia.org/wikipedia/en/wiki/Regexp#POSIX_Basic_Regular_Expressions
> the construct \( ... \) and \1 up to \9 was not retained in
> POSIX regexpes. 
> 
> About the given problem, one idea would be to return the
> start of the regexp
> '\d+' and to check if the start falls inside some allowed
> range:
> regexp('WA 053 011 Clark County 123     
>       45 ', '\d+') 
> ans= 
>         4   
> 8   25   40
> and skip the third reply, because it falls inside a range
> where numeric are
> not relevant.
> 
> Regards
> 
> Pascal
> -- 
> View this message in context: 
> http://octave.1599824.n4.nabble.com/Specific-fixed-width-question-tp2539259p2541930.html
> Sent from the Octave - General mailing list archive at
> Nabble.com.
> _______________________________________________



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.

Regards,
  Sergei.


      



reply via email to

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