I have this string.
string str = "5595176&cn=ANY&ln=ADdedfr";
I need to replace ANY to 12345
string str = "5595176&cn=12345&ln=ADdedfr
string ANY may be different.
I have this string.
string str = "5595176&cn=ANY&ln=ADdedfr";
I need to replace ANY to 12345
string str = "5595176&cn=12345&ln=ADdedfr
string ANY may be different.
This might do the trick for you
using System.Text.RegularExpressions;
string mystr = Regex.Replace(str, "cn=[A-Za-z]+", "cn=12345");
According to the comment it could be
using System.Text.RegularExpressions;
string mystr = Regex.Replace(str, "cn=[A-Za-z]+", "cn=" + CountryCode);