VS regular expression replacement content, vs regular expression replacement
Rarely use the regular expression replacement function of VS. Recently, because a large number of default values need to be added, but you don't want to re-class, you just thought of this.
1. Replace attributes with // descriptions
The regular expression to be searched:
/// <Summary> ((.) *((. | \ n) {1, 2}) {1, 2 }///(. {1 ,})((.) *((. | \ n) {1, 2}) {1, 2} // </summary> ((.) *((. | \ n) {1, 2}) {1, 2} public string (. {1 ,}) {get; set ;}
Replace the regular expression:
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}
$1... $ n indicates the matching items. Most of the time it is calculated by yourself, it may be incorrect. In this way, where to replace it: $1; $2 ;....; $ n in this way, you can intuitively know that it is the value you want. In the above replace expression, $5 is the comment content, and $14 is the attribute name;
2. Replace uncommented attributes
The regular expression to be searched:
Public string (. {1,}) {get; set ;}
Replace the regular expression:
\ Nprivate string _ $1; \ n // <summary> \ n // $1 \ n // </summary> \ n public string $1 {\ nget \ n {\ nif (string. isNullOrWhiteSpace (_ $1) \ n {\ n _ $1 = ""; \ n} \ nreturn _ $1; \ n} \ nset \ n {\ n _ $1 = value; \ n}
Here is a simple usage.