C # Replace and remove HTML tags

Source: Internet
Author: User

1. Many people have encountered the problem of unsuccessful replacement of string Replace.

String aa = "Dear $ name, thank you for choosing this website. Your order $ no on this website has been submitted successfully. Please complete the payment within 2 hours, so that we can deliver the goods to you as soon as possible. If you have any questions, please call: 4007-336-337 ";
Aa. Replace ("$ name", "ceshi000 ");
Aa. Replace ("$ no", "2012090400032 ");
Response. Write (aa );

The above Code shows that there is no problem, but the replacement fails. Why?

The reason is that you need to assign a value to the string aa again during replacement, as shown below:

String aa = "Dear $ name, thank you for choosing this website. Your order $ no on this website has been submitted successfully. Please complete the payment within 2 hours, so that we can deliver the goods to you as soon as possible. If you have any questions, please call: 4007-336-337 ";
Aa = aa. Replace ("$ name", "ceshi000 ");
Aa = aa. Replace ("$ no", "2012090400032 ");
Response. Write (aa); www.2cto.com

In this way, the replacement is successful.

2. during development, some of the content contains HTML tags, which are sometimes not needed. How can this problem be removed? As follows:

String Smes = System. Text. RegularExpressions. Regex. Replace (message, "<. *?> "," "). Replace (" & nbsp ;","");

Note: message contains HTML tags.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.