c# - How to Format a string to be a part of URL? -
I need to delete all the characters that are not part of the URL, such as spaces, & lt;,> and more
I am getting the data from the database. For example: if data has been received: Product number # 123!
New string should be: Product number -123
Should I use Regex? Is there a regex pattern for that? Thanks
An easy regex to do this:
string Clean = Regex.Replace (url, @ "[^ a-zA-Z0- 9] +", "-");
Comments
Post a Comment