How do I replace a specific occurrence of a string in a string?

后端 未结 7 1542
野的像风
野的像风 2020-12-18 03:12

I have a string which may contain \"title1\" twice in it.

e.g.

server/api/shows?title1=its always sunny in philadelphia&title1=breaking ba

7条回答
  •  春和景丽
    2020-12-18 03:55

    You could perhaps make use of a negative lookahead:

    title1(?!.*title1)
    

    And replace with title2.

    See how it's working here.

提交回复
热议问题