STREGEX Help Please [message #77682] |
Mon, 19 September 2011 04:18 |
rjp23
Messages: 97 Registered: June 2010
|
Member |
|
|
Hi,
I'm trying to convert some IDL code into GDL and ran into the problem
that GDL doesn't support STRMATCH which we were using extensively. It
does however support STREGEX and I've just about got it working but
wanted to check that I was doing it correctly.
In IDL we had something like:
alt=column_data[where(strmatch(column_header, 'alt'))]
In GDL using stregex I thought the equivalent was: alt =
column_data[where(stregex(column_header, 'alt',/boolean))]
However, this introduced the problem that it also matched any strings
containing alt anywhere within them (for example, "p_alt").
I think the solution is to use anchors like so:
alt = column_data[where(stregex(column_header, '^alt$',/boolean))]
This way, it'll match the string which is (and only is) what we're
trying to match.
Have I got this right? It seems to work but I'm not 100% that it's
robust. Have I done anything stupid or missed an easier solution?
Cheers
|
|
|