Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: None  |  size: 0.47 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. "find several string with regular expresions
  2. # I would like to find either "-hex", "-mos", or "-sig"
  3. # the result would be -hex, -mos, or -sig
  4. # You see I want to get rid of the double quotes around these three strings.
  5. # Other double quoting is OK.
  6. # I'd like something like.
  7. messWithCommandArgs =  ' -o {} "-sig" "-r" "-sip" '
  8. messWithCommandArgs = re.sub(
  9.             r'"(-[hex|mos|sig])"',
  10.             r"1",
  11.             messWithCommandArgs)
  12.        
  13. r'"(-(?:hex|mos|sig))"'