resolve environment variables in string - regular expression

Kai Rosenthal kairosenthal at tiscali.de
Fri Feb 9 06:30:42 EST 2007


Hello,

how can I resolve envionment variables in a string.
e.g.

strVar = /myVar
resolve in
str1 = /mytest02/$MYVAR/mytest02     --> /mytest02//myVar/mytest02
(unix)
str2 =$MYVAR/mytest03     --> /myVar/mytest03 (unix)
str3 =%MYVAR%/mytest03     --> /myVar/mytest03 (windows)
I would not set the variables in this time.

I think I need a little regular expression code snippet, but I have
not work with regular expression before.

Thanks for your help, Kai.




More information about the Python-list mailing list