comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » regular expressions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Regular Expressions [message #24240 is a reply to message #15713] Tue, 20 March 2001 12:14 Go to previous messageGo to previous message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
"Pavel A. Romashkin" wrote:

> Wouldn't it be easier to analyse a byte array with more human-readible
> functions, than those beautiful regular expressions you guys brought up?
>

It depends on what you mean by "easier". One nice thing about STREGEX is
that it works on vector strings. One can always convert the string
array to a byte array and analyze, but -- **if you are trying to avoid
loops** -- the indexing can be become extremely opaque, and exercise at
least as many brain cells as using STREGEX. For example, JD's solution
can also apply to a string array where one is trying to extract the
substrings beginning and ending with a singe quote:

IDL> st = ["value1 = 'Wayne''s dog' / First string ", $
"value2 = 'Sue''s dog and Ralph''s cat' / Second string ", $
"value3 = 'two pigeons'" ]

IDL> val = (stregex(st, /SUBEXPR,/EXTRACT,"= *'(.*)'([^']|$)"))[1,*]
IDL> print,val
Wayne''s dog
Sue''s dog and Ralph''s cat
two pigeons

Of course, one should probably add an English comment to the use of STRGEX

; Find the substring beginning with an "=", followed by any number of
characters,
; followed by a quote, followed by any number of characters (including
double
; quotes) up to the last single quote. Extract from this substring all
; characters between the first and last single quotes.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Time convertion
Next Topic: Re: curvefit Q

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 23:00:42 PDT 2025

Total time taken to generate the page: 0.95724 seconds