Hi nauna,
Refer below code.
C#
protected void Page_Load(object sender, EventArgs e)
{
string s = "Gold, silver";
s = createurlpath(s);
Response.Write(s);
}
public string createurlpath(string value)
{
string returnpath = System.Text.RegularExpressions.Regex.Replace(value, @"(\s+|\.|\,|\:|\*|&|\?|\/)", "-");
return returnpath.Replace("--", "-");
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim s As String = "Gold, silver"
s = createurlpath(s)
Response.Write(s)
End Sub
Public Function createurlpath(ByVal value As String) As String
Dim returnpath As String = System.Text.RegularExpressions.Regex.Replace(value, "(\s+|\.|\,|\:|\*|&|\?|\/)", "-")
Return returnpath.Replace("--", "-")
End Function
Output
Gold-silver