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

Home » Public Forums » archive » Re: Using STREGEX/STRMID
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: Using STREGEX/STRMID [message #71277] Wed, 09 June 2010 14:01 Go to previous message
fgg is currently offline  fgg
Messages: 67
Registered: April 2010
Member
On Jun 9, 12:23 pm, Craig Markwardt <craig.markwa...@gmail.com> wrote:
> On Jun 9, 2:19 pm, fgg <fabioguimaraesgoncal...@gmail.com> wrote:
>
>> Hello,
>
>> I'd like to get the "label" (i.e. 1033) from this string:
>
>> IDL> str = '; ROI name: EVF: Layer: pts_slant.shp (Label=1033)'
>
>> ...and I was wondering if there is a more elegant/efficient way of
>> doing this than:
>
>> IDL> pos0 = stregex(str, '=')+1
>> IDL> posn = stregex(str, ')')
>> IDL> print, strmid(str, pos0, posn-pos0)
>
> You want the substring option of STREGEX,
>
> str = stregex(str, '\(Label=([0-9]*)\)', /extract, /sub)
> print, str[1]
> 1033
>
> The zeroth substring is the full match.
> The first substring is the one enclosed in parentheses.  It's a little
> confusing because the () are used to enclose regex substrings and \(\)
> are the literal parentheses expected to appear in the string.
>
> Craig

Perfect. Thank you, Craig.
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Object within an Object's Structure
Next Topic: Creating a sub array from an array

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

Current Time: Thu Oct 09 23:07:45 PDT 2025

Total time taken to generate the page: 0.24002 seconds