VS Regular Expression Replace content

Source: Internet
Author: User

There is little use of the regular replacement of VS, which is most recently due to the need to add a large number of default values, but do not want to re-class.

1. Replace the attribute with///description

To find a regular expression:

<summary> (.) *((.| \ n}) {1,2}///(. { 1,}) ((.) *((.| \ n) {1,2}///})) {</summary> (.) *((.| \ n}) {1,2}public string (. { 1,}) {get; set;}

Regular expression to replace:

private string _$14;\n///<summary>\n///$5\n///</summary>\n public string $14 {\nget\n{\nif (string. Isnullorwhitespace (_$14)) \n{\n _$14 = ""; \ n} \nreturn _$14; \ n} \nset \n{\n _$14 = value; \ n} \ n}

Where $ $ ... $n, representing the first few matches, many times it may not be correct when you calculate it, so it's in place of the replacement: $1;$2; $n so you can be very intuitive to know that is the value you want, in the above substitution expression is the comment content, $14 is the attribute name;

2. Replace the attributes that are not annotated

To find a regular expression:

public string (. { 1,}) {get; set;}

Regular expression to replace:

\nprivate string _$1;\n///<summary>\n///$1\n///</summary>\n public string $ {\nget\n{\nif (string. Isnullorwhitespace (_$1)) \n{\n _$1 = ""; \ n} \nreturn _$1; \ n} \nset \n{\n _$1 = value; \ n} \ n}

This just describes a simple usage.

VS Regular Expression Replace content

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.