我有一个字符串,其中可能包含两个"title1"。
例如:
server/api/shows?title1=its always sunny in philadelphia&title1=breaking bad ...
我需要将第二个"title1"更改为"title2"。
我已经知道如何确定字符串中是否有两个该字符串的实例。
例如:
server/api/shows?title1=its always sunny in philadelphia&title1=breaking bad ...
我需要将第二个"title1"更改为"title2"。
我已经知道如何确定字符串中是否有两个该字符串的实例。
int occCount = Regex.Matches(callingURL, "title1=").Count;
if (occCount > 1)
{
//here's where I need to replace the second "title1" to "title2"
}
我知道我们可能可以在这里使用正则表达式,但我无法在第二个实例上进行替换。有人能帮帮我吗?
title1
单词实例,你需要将第三个更改为title3
吗? - Sam I am says Reinstate Monica