Re: Curious to see alternate approach on a search/replace via regex

Discussion in 'Python' started by Serhiy Storchaka, Feb 7, 2013.

  1. On 07.02.13 11:49, Peter Otten wrote:
    > ILLEGAL = "-:./?&="
    > try:
    > TRANS = string.maketrans(ILLEGAL, "_" * len(ILLEGAL))
    > except AttributeError:
    > # python 3
    > TRANS = dict.fromkeys(map(ord, ILLEGAL), "_")


    str.maketrans()
    Serhiy Storchaka, Feb 7, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rh
    Replies:
    6
    Views:
    115
    Nick Mellor
    Feb 8, 2013
  2. Demian Brecht
    Replies:
    18
    Views:
    211
  3. Demian Brecht
    Replies:
    0
    Views:
    120
    Demian Brecht
    Feb 6, 2013
  4. MRAB
    Replies:
    0
    Views:
    98
  5. Peter Otten
    Replies:
    0
    Views:
    79
    Peter Otten
    Feb 7, 2013
Loading...

Share This Page