python regular expression replacing part of a matched string

后端 未结 5 741
粉色の甜心
粉色の甜心 2020-12-16 18:57

i got an string that might look like this

\"myFunc(\'element\',\'node\',\'elementVersion\',\'ext\',12,0,0)\"

i\'m currently checking for va

5条回答
  •  旧巷少年郎
    2020-12-16 19:04

    If you want to do this without using regex:

    >>> s = "myFunc('element','node','elementVersion','ext',12,0,0)"
    >>> l = s.split(",")
    >>> l[2]="'noVersion'"
    >>> s = ",".join(l)
    >>> s
    "myFunc('element','node','noVersion','ext',12,0,0)"
    

提交回复
热议问题