Regular expression replace except first and last characters

前端 未结 3 429
一个人的身影
一个人的身影 2021-01-20 08:42

What is a regular expression to replace doublequotes (\") in a string with escape backslash followed by doublequotes (\\\") except at the first and last characters of the s

3条回答
  •  悲&欢浪女
    2021-01-20 09:11

    As pointed out by @mgilson, you can just slice the first and last characters off so this regex is basically pointless

    >>> print re.sub(r'(?>> print re.sub(r'(?

提交回复
热议问题