Variables in REs

Y

Yoav

Anyway to set variables in REs. Meaning:
I have the RE re.compile(r'/[^/]*') for example and I want to use it on
both Win32 machines and Unix machnes. Meaning tha tI need to be able to
control the '/' before compiling. I want to create and if and decide
what the system is and then put the right char in a variable and compile
the RE using that varialbe. I am quite a noob, so I know the question
might sound stupid, but any help will be appreciated.

Thanks.
 
T

tooper

Use os.sep to get / or \ or whatever character used to build pathes on
the os you're working on
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top