Regular Expression form MSDN

原创 2006年05月25日 18:14:00

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.

Note   You 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 except 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.

Repeat n times

^n

Matches n occurrences of the preceding expression. For example, [0-9]^4 matches 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) bath matches "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 by the nth tagged expression, where n is 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-justifies the nth tagged expression in a field at least w characters wide.

Left-justified field

/(-w,n)

In a Replace expression, left-justifies the nth tagged expression in a field at least w characters 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

:a

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, :Luhe matches "The" but not "the".

Lowercase letter

:Ll

Matches any one lower case letter. For example, :Llhe matches "the" but not "The".

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, :Alhe matches words such as "The", "then", and "reached".

Numeric

:Nu

Matches any one number or digit.

Punctuation

:Pu

Matches any one punctuation mark, such as ?, @, ', 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.

 

10. Regular Expression Matching(很重要!!!)

Implement regular expression matching with support for '.' and '*'. '.' Matches any single character...
  • gao1440156051
  • gao1440156051
  • 2016年08月15日 17:15
  • 756

转贴 Regular Expression 简介(正则表达式)

引用:Regular Expression 简介 中央研究院计算中心 ASPAC 计划 aspac@phi.sinica.edu.tw 技术报告: 94019 1995 年 2 月 9 日 Vers...
  • chj90220
  • chj90220
  • 2012年12月09日 22:20
  • 1333

正则表达式 Regular Expression

重新整理记录一下正则规则 定义 Regular Expression - 正规的/有规律的表达式,是计算机科学的一个概念。使用一个字符串来描述、匹配一系列符合某个句法规则的字符串 最...
  • u010297957
  • u010297957
  • 2016年04月05日 17:06
  • 684

正则表达式(Regular Expression)基本语法

一、简介 为什么需要正则表达式? 文本的复杂处理正则表达式的优势和用途? 一种强大而灵活的文本处理工具; 大部分编程语言、数据库、文本编辑器、开发环境都支持正则表达式。正则表达式定义: 正如...
  • scgaliguodong123_
  • scgaliguodong123_
  • 2015年04月29日 22:00
  • 4115

[LeetCode][10]Regular Expression Matching解析 -Java实现

Q: Implement regular expression matching with support for '.' and '*'. '.' Matches any single ...
  • u014629433
  • u014629433
  • 2016年06月11日 14:38
  • 1954

【LeetCode010算法/编程练习C++】Regular Expression Matching//挺烦的一条……

10. Regular Expression Matching Total Accepted: 113015 Total Submissions: 481908 Difficulty: ...
  • zmdsjtu
  • zmdsjtu
  • 2016年12月27日 16:09
  • 542

10. Regular Expression Matching-动态规划/递归回溯

mplement regular expression matching with support for '.' and '*'. '.' Matches any single character...
  • u011567017
  • u011567017
  • 2016年09月11日 21:40
  • 597

Syntax error on token "Invalid Regular Expression Options", no accurate corr

1、选中报错的文件 2、右键选择 MyEclipse-->Exclude From Validation  3、再右键选择 MyEclipse-->Run Validation...
  • tianya9006
  • tianya9006
  • 2016年03月11日 16:36
  • 1524

浅谈正则表达式(Regular Expression)

一、什么是正则表达式? 简单的说:正则表达式(Regular Expression)是一种处理字符串匹配的语言; 正则表达式描述了一种字符串匹配的模式,可以用来检查一个字符串是否含有某种子串,对匹...
  • u014421422
  • u014421422
  • 2015年01月07日 09:17
  • 479

[Python]Regular Expression Syntax(CHN)

简介Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式。Python 1.5之前版本则是通过 regex 模块提供 Emecs 风格的模式。Emacs 风格模式可读性...
  • formX
  • formX
  • 2007年10月09日 17:31
  • 2151
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Regular Expression form MSDN
举报原因:
原因补充:

(最多只允许输入30个字)