Use regular expressions in Visual Studio for search and replacement

Source: Internet
Author: User
Tags alphabetic character control characters

Today, I decomcompiled a project, and the form of the property in it is changed to the original form, such as get_xxx (), set_xxx (VAL), and there are still many. It takes a lot of time to manually change it, therefore, I want to replace the regular expression with the group match. I checked the information and used the group symbol {} In vs. It seems that I cannot use, I tried it many times but failed, for example:

To replace obj. get_name () with obj. Name, you can use

Get _ {[^ (] + }\(\)
Replace
\ 1

Then, \ 1 is equivalent to {[^ \ (] +}, and ^ \ (represents all the characters not in the left brackets ).

If you want to replace obj. set_name ("ABCD") with obj. Name = "ABCD", you can use the following method:
Set _ {[^ \ (] +} \ ({[^ \)] + }\)
Replace
\ 1 = \ 2
In addition, in:
: W can match ([a-zA-Z0-9]).
: C can be matched ([A-Za-Z]).
: D can be matched ([0-9]).
\NRepresents the substring captured in the group match. 1-9 represents the first to ninth substring, that is, \ 1-\ 9, \ 0 represents the entire matched substring.

Msdn provides a detailed description, but only in English. The address is as follows:
Http://msdn.microsoft.com/en-us/library/2k3te2cs (vs.71). aspx
The text is referenced below:

Visual Studio

Regular Expressions

Regular Expressions are a concise and flexible notation for finding and replacing patterns of text. the regular expressions used within Visual Studio are a superset of the expressions used in Visual C ++ 6.0, with a simplified syntax.

You can use the following regular expressions in the find, replace, find in files or replace in files dialog boxes to refine and expand your search.

NoteYou must select the use check box in the find, replace, find in files, and replace in files dialog boxes before using any of the following expressions as part of your search criteria.

The following expressions can be used to match characters or digits in your search string:

Expression
Syntax
Description

Any character
.
Matches any one character t a line break.

Maximal-zero or more
*
Matches zero or more occurrences of the preceding expression.

Maximal-one or more
+
Matches at least one occurrence of the preceding expression.

Minimal-zero or more
@
Matches zero or more occurrences of the preceding expression, matching as few characters as possible.

Minimal-one or more
#
Matches one or more occurrences of the preceding expression, matching as few characters as possible.

RepeatNTimes
^N
MatchesNOccurrences of the preceding expression. For example,[0-9]^4Matches any 4-digit sequence.

Set of characters
[]
Matches any one of the characters within the []. To specify a range of characters, list the starting and ending character separated by a dash (-), as in [A-Z].

Character not in Set
[^...]
Matches any character not in the set of characters following the ^.

Beginning of Line
^
Anchors the match to the beginning of a line.

End of line
$
Anchors the match to the end of a line.

Beginning of Word
<
Matches only when a word begins at this point in the text.

End of Word
>
Matches only when a word ends at this point in the text.

Grouping
()
Groups a subexpression.

Or
|
Matches the expression before or after the or symbol (|). Mostly used within a group. For example,(sponge|mud) bathMatches "sponge bath" and "mud bath ."

Escape
\
Matches the character following the backslash (\). This allows you to find characters used in the regular expression notation, such as {and ^. For example,\^Searches for the ^ character.

Tagged expression
{}
Tags the text matched by the enclosed expression.

NTh tagged text
\N
In a find or replace expression, indicates the text matched byNTh tagged expression, whereNIs a number from 1 to 9.

In a replace expression, \ 0 inserts the entire matched text.

Right-justified Field
\(W,N)
In a replace expression, right-justifiesNTh tagged expression in a field at leastWCharacters wide.

Left-justified Field
\(-W,N)
In a replace expression, left-justifiesNTh tagged expression in a field at leastWCharacters wide.

Prevent match
~ (X)
Prevents a match when x appears at this point in the expression. For example,real~(ity)Matches the "real" in "realty" and "Really," but not the "real" in "reality ."

Alphanumeric character
:
Matches the expression
([A-zA-Z0-9]).

Alphabetic character
: C
Matches the expression
([A-Za-Z]).

Decimal digit
: D
Matches the expression
([0-9]).

Hexadecimal digit
: H
Matches the expression
([0-9a-fa-f] + )..

Identifier
: I
Matches the expression
([A-Za-Z _ $] [a-zA-Z0-9 _ $] *).

Rational Number
: N
Matches the expression
([0-9] +. [0-9] *) | ([0-9] *. [0-9] +) | ([0-9] + )).

Quoted string
: Q
Matches the expression ("[^"] * ") | ('[^'] * ')

Alphabetic string
: W
Matches the expression
([A-Za-Z] +)

Decimal integer
: Z
Matches the expression
([0-9] + ).

Escape
\ E
Unicode U + 001b.

Bell
\ G
Unicode U + 0007.

Backspace
\ H
Unicode U + 0008.

Line Break
\ N
Matches a platform-independent line break. In a replace expression, inserts a line break.

Tab
\ T
Matches a Tab character, Unicode U + 0009.

Unicode Character
\ X #### or \ U ####
Matches a character given by Unicode value where ### is hexadecimal digits. you can specify a character outside the basic multilingual plane (that is, a surrogate) with the ISO 10646 code point or with two Unicode code points giving the values of the surrogate pair.

The following table lists the syntax for matching by standard UNICODE character properties. the two-letter abbreviation is the same as listed in the Unicode character properties database. these may be specified as part of a character set. for example, the expression [: Nd: NL: No] matches any kind of digit.

Expression
Syntax
Description

Uppercase letter
: Lu
Matches any one capital letter. For example,:LuheMatches "the" but not "".

Lowercase letter
: LL
Matches any one lower case letter. For example,:LlheMatches "the" but not "".

Title case letter
: Lt
Matches characters that combine an uppercase letter with a lowercase letter, such as NJ and DZ.

Modifier letter
: LM
Matches letters or punctuation, such as commas, cross accents, and double Prime, used to indicate modifications to the preceding letter.

Other letter
: Lo
Matches other letters, such as gothic letter ahsa.

Decimal digit
: Nd
Matches decimal digits such as 0-9 and their full-width equivalents.

Letter Digit
: NL
Matches letter digits such as Roman numerals and Ideographic number zero.

Other Digit
: No
Matches other digits such as old italic number one.

Open punctuation
: PS
Matches opening punctuation such as open brackets and braces.

Close punctuation
: PE
Matches closing punctuation such as closing brackets and braces.

Initial quote punctuation
: Pi
Matches initial double quotation marks.

Final quote punctuation
: Pf
Matches single quotation marks and ending double quotation marks.

Dash punctuation
: PD
Matches the dash mark.

Connector punctuation
: PC
Matches the underscore or underline mark.

Other punctuation
: Po
Matches commas (,),?, ",!, @, #, %, &, *, \, Colons (:), semi-colons (;), ', And /.

Space Separator
: Zs
Matches blanks.

Line Separator
: ZL
Matches the Unicode Character U + 2028.

Paragraph Separator
: ZP
Matches the Unicode Character U + 2029.

Non-spacing mark
: Mn
Matches non-spacing marks.

Combining mark
: MC
Matches combining marks.

Enclosing mark
: Me
Matches enclosing marks.

Math symbol
: Sm
Matches +, = ,~, |, <, And>.

Currency symbol
: SC
Matches $ and other currency symbols.

Modifier symbol
: SK
Matches modifier symbols such as circumflex accent, grave accent, and macron.

Other symbol
: So
Matches other symbols, such as the copyright sign, pilcrow sign, and the Degree sign.

Other Control
: CC
Matches end of line.

Other format
: Cf
Formatting control character such as the bidirectional control characters.

Surrogate
: CS
Matches one half of a surrogate pair.

Other private-Use
: Co
Matches any character from the private-use area.

Other not assigned
: CN
Matches characters that do not map to a Unicode character.

In addition to the standard UNICODE character properties, the following additional properties may be specified. These properties may be specified as part of a character set.

Expression
Syntax
Description

Alpha
: Al
Matches any one character. For example,:AlheMatches words such as "the", "then", and "reached ".

Numeric
: Nu
Matches any one number or digit.

Punctuation
: PU
Matches any one punctuation mark, Such ?, @, ', And so on.

White space
: Wh
Matches all types of white space, including publishing and Ideographic spaces.

Bidi
: Bi
Matches characters from right-to-left scripts such as Arabic and Hebrew.

Hangul
: Ha
Matches Korean hangul and combining jamos.

Hiragana
: Hi
Matches hiragana characters.

Katakana
: Ka
Matches katakana characters.

Ideographic/Han/Kanji
: ID
Matches ideographic characters, such as Han and kanji.

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.