Re: regular expressions (parsing strings) [message #36947] |
Thu, 13 November 2003 09:33 |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"setthivoine you" <noone@nowhere.com> wrote in message
news:bou3o6$ajs$1@naig.caltech.edu...
> Hi,
>
> My IDL programs need to parse a text file which contains variables
that
> would need replacing at read-time. Specifically:
>
>
> #os =unix
> #windows_var1 =g:
> #windows_var2 =/rootdir/
> #unix_var1 =/mnt/groupserver/
> #unix_var2 =/rootdir/
> #var3 =< <os>_var1 >< <os>_var2 >data/
> #var4 =<var3>counterfile.txt
>
>
> So #var3 eventually becomes '/mnt/groupserver/rootdir/data/' and #var4
> becomes 'mnt/groupserver/rootdir/data/counterfile.txt'. And if #os was
> set to 'windows', #var4 becomes 'g:/rootdir/data/counterfile.txt'.
>
> I am trying to use regular expressions to replace the text
(specifically
> using strepex.pro from
> http://astro.uni-tuebingen.de/software/idl/aitlib/misc/strep ex.html )
> but am having problems with nested tags.
>
> Could anyone point me to somewhere that could help me out ?
Hi,
If you are using IDL >= 5.3, StRegEx is now built into IDL. It's quite
flexible and has worked well for me, but your problem may not be suited
to regular expressions. I found this article "Finding nested expressions
in regexs" from newsgroup comp.lang.python through Google:
http://groups.google.com/groups?th=ed6a75bc5eed7ee9&seek m=000401be9e6d%2
427a98ec0%24029e2299
If you can be more specific, maybe there is more we can do.
Cheers,
--
-Dick
Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
|
|
|