Variables in REs

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yoav

    #1

    Variables in REs

    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.
  • tooper

    #2
    Re: Variables in REs

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

    Comment

    • Yoav

      #3
      Re: Variables in REs

      Such a sweet and simple way.

      Thanks.

      tooper wrote:[color=blue]
      > Use os.sep to get / or \ or whatever character used to build pathes on
      > the os you're working on
      >[/color]

      Comment

      Working...