Summary of regular-expression constructs
Construct
Matches
Characters
x
The character x
\\
The backslash character
\0n
The character with octal value 0n (0 <= n <= 7)
\0nn
The character with octal value 0nn (0 <= n <= 7)
\0mnn
The character with octal value 0mnn (0 <= m <= 3, 0 <= n <= 7)
\xhh
The character with hexadecimal value 0xhh
\uhhhh
The character with hexadecimal value 0xhhhh
\t
The tab character ('\u0009')
\n
The newline (line feed) character ('\u000A')
\r
The carriage-return character ('\u000D')
\f
The form-feed character ('\u000C')
\a
The alert (bell) character ('\u0007')
\e
The escape character ('\u001B')
\cx
The control character corresponding to x
Character classes
[abc]
a, b, or c (simple class)
[^abc]
Any character except a, b, or c (negation)
[a-zA-Z]
a through z or A through Z, inclusive (range)
[a-d[m-p]]
a through d, or m through p: [a-dm-p] (union)
[a-z&&[def]]
d, e, or f (intersection)
[a-z&&[^bc]]
a through z, except for b and c: [ad-z] (subtraction)
[a-z&&[^m-p]]
a through z, and not m through p: [a-lq-z](subtraction)
Predefined character classes
.
Any character (may or may not match line terminators)
\d
A digit: [0-9]
\D
A non-digit: [^0-9]
\s
A whitespace character: [ \t\n\x0B\f\r]
\S
A non-whitespace character: [^\s]
\w
A word character: [a-zA-Z_0-9]
\W
A non-word character: [^\w]
POSIX character classes (US-ASCII only)
\p{Lower}
A lower-case alphabetic character: [a-z]
\p{Upper}
An upper-case alphabetic character:[A-Z]
\p{ASCII}
All ASCII:[\x00-\x7F]
\p{Alpha}
An alphabetic character:[\p{Lower}\p{Upper}]
\p{Digit}
A decimal digit: [0-9]
\p{Alnum}
An alphanumeric character:[\p{Alpha}\p{Digit}]
\p{Punct}
Punctuation: One of !"#$%&'()*+,-./:;=>?@[\]^_`{|}~
\p{Graph}
A visible character: [\p{Alnum}\p{Punct}]
\p{Print}
A printable character: [\p{Graph}\x20]
\p{Blank}
A space or a tab: [ \t]
\p{Cntrl}
A control character: [\x00-\x1F\x7F]
\p{XDigit}
A hexadecimal digit: [0-9a-fA-F]
\p{Space}
A whitespace character: [ \t\n\x0B\f\r]
java.lang.Character classes (simple java character type)
\p{javaLowerCase}
Equivalent to java.lang.Character.isLowerCase()
\p{javaUpperCase}
Equivalent to java.lang.Character.isUpperCase()
\p{javaWhitespace}
Equivalent to java.lang.Character.isWhitespace()
\p{javaMirrored}
Equivalent to java.lang.Character.isMirrored()
Classes for Unicode blocks and categories
\p{InGreek}
A character in the Greek block (simple block)
\p{Lu}
An uppercase letter (simple category)
\p{Sc}
A currency symbol
\P{InGreek}
Any character except one in the Greek block (negation)
[\p{L}&&[^\p{Lu}]]
Any letter except an uppercase letter (subtraction)
Boundary matchers
^
The beginning of a line
$
The end of a line
\b
A word boundary
\B
A non-word boundary
\A
The beginning of the input
\G
The end of the previous match
\Z
The end of the input but for the final terminator, if any
\z
The end of the input
Greedy quantifiers
X?
X, once or not at all
X*
X, zero or more times
X+
X, one or more times
X{n}
X, exactly n times
X{n,}
X, at least n times
X{n,m}
X, at least n but not more than m times
Reluctant quantifiers
X??
X, once or not at all
X*?
X, zero or more times
X+?
X, one or more times
X{n}?
X, exactly n times
X{n,}?
X, at least n times
X{n,m}?
X, at least n but not more than m times
Possessive quantifiers
X?+
X, once or not at all
X*+
X, zero or more times
X++
X, one or more times
X{n}+
X, exactly n times
X{n,}+
X, at least n times
X{n,m}+
X, at least n but not more than m times
Logical operators
XY
X followed by Y
X|Y
Either X or Y
(X)
X, as a capturing group
Back references
\n
Whatever the nth capturing group matched
Quotation
\
Nothing, but quotes the following character
\Q
Nothing, but quotes all characters until \E
\E
Nothing, but ends quoting started by \Q
Special constructs (non-capturing)
(?:X)
X, as a non-capturing group
(?idmsux-idmsux)
Nothing, but turns match flags on - off
(?idmsux-idmsux:X)
X, as a non-capturing group with the given flags on - off
(?=X)
X, via zero-width positive lookahead
(?!X)
X, via zero-width negative lookahead
(?<=X)
X, via zero-width positive lookbehind
(?<!X)
X, via zero-width negative lookbehind
(?>X)
X, as an independent, non-capturing group
More on Regular Expressions: Full Java Regular Expressions syntax description, Using Regular Expressions in Java.
webstorm搜索說明
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進(jìn)店門干签,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人拆撼,你說我怎么就攤上這事容劳。” “怎么了闸度?”我有些...
- 文/不壞的土叔 我叫張陵竭贩,是天一觀的道長。 經(jīng)常有香客問我莺禁,道長娶视,這世上最難降的妖魔是什么? 我笑而不...
- 正文 為了忘掉前任睁宰,我火速辦了婚禮,結(jié)果婚禮上寝凌,老公的妹妹穿的比我還像新娘柒傻。我一直安慰自己,他們只是感情好较木,可當(dāng)我...
- 文/花漫 我一把揭開白布红符。 她就那樣靜靜地躺著,像睡著了一般伐债。 火紅的嫁衣襯著肌膚如雪预侯。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼峭竣,長吁一口氣:“原來是場噩夢啊……” “哼塘辅!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起皆撩,我...
- 序言:老撾萬榮一對情侶失蹤扣墩,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后扛吞,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體呻惕,經(jīng)...
- 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
- 正文 我和宋清朗相戀三年喻粹,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了蟆融。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
- 正文 年R本政府宣布,位于F島的核電站玛迄,受9級特大地震影響由境,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜蓖议,卻給世界環(huán)境...
- 文/蒙蒙 一虏杰、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧勒虾,春花似錦纺阔、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至愕宋,卻和暖如春玻靡,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背中贝。 一陣腳步聲響...
- 正文 我出身青樓最蕾,卻偏偏與公主長得像依溯,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個(gè)殘疾皇子瘟则,可洞房花燭夜當(dāng)晚...
推薦閱讀更多精彩內(nèi)容
- ES是一個(gè)基于RESTful web接口并且構(gòu)建在Apache Lucene之上的開源分布式搜索引擎黎炉。 es 全文...
- 但JBrowse要展示數(shù)據(jù)達(dá)到一定量級之后,如何方便管理這些track就成了一個(gè)問題醋拧,JBrowse支持三種tra...
- 原文地址:Exposing the Searchbar Implementing a Dialer-like Se...
- 前言:jacman主題默認(rèn)提供的google慷嗜、baidu還有tinysou三種搜索,很是讓我無語丹壕,不是被墻就是極度...
- 5月以來堕绩,哪怕對市場風(fēng)向再不敏感的人,也感覺到陣陣涼意邑时。二級市場連續(xù)下挫奴紧,一級市場融資環(huán)境惡化,不論企業(yè)融資數(shù)量還...