github.com/varialus/godfly@v0.0.0-20130904042352-1934f9f095ab/src/pkg/regexp/syntax/doc.go (about) 1 // Copyright 2012 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // DO NOT EDIT. This file is generated by mksyntaxgo from the RE2 distribution. 6 7 /* 8 Package syntax parses regular expressions into parse trees and compiles 9 parse trees into programs. Most clients of regular expressions will use the 10 facilities of package regexp (such as Compile and Match) instead of this package. 11 12 Syntax 13 14 The regular expression syntax understood by this package when parsing with the Perl flag is as follows. 15 Parts of the syntax can be disabled by passing alternate flags to Parse. 16 17 18 Single characters: 19 . any character, possibly including newline (flag s=true) 20 [xyz] character class 21 [^xyz] negated character class 22 \d Perl character class 23 \D negated Perl character class 24 [:alpha:] ASCII character class 25 [:^alpha:] negated ASCII character class 26 \pN Unicode character class (one-letter name) 27 \p{Greek} Unicode character class 28 \PN negated Unicode character class (one-letter name) 29 \P{Greek} negated Unicode character class 30 31 Composites: 32 xy x followed by y 33 x|y x or y (prefer x) 34 35 Repetitions: 36 x* zero or more x, prefer more 37 x+ one or more x, prefer more 38 x? zero or one x, prefer one 39 x{n,m} n or n+1 or ... or m x, prefer more 40 x{n,} n or more x, prefer more 41 x{n} exactly n x 42 x*? zero or more x, prefer fewer 43 x+? one or more x, prefer fewer 44 x?? zero or one x, prefer zero 45 x{n,m}? n or n+1 or ... or m x, prefer fewer 46 x{n,}? n or more x, prefer fewer 47 x{n}? exactly n x 48 49 Grouping: 50 (re) numbered capturing group (submatch) 51 (?P<name>re) named & numbered capturing group (submatch) 52 (?:re) non-capturing group (submatch) 53 (?flags) set flags within current group; non-capturing 54 (?flags:re) set flags during re; non-capturing 55 56 Flag syntax is xyz (set) or -xyz (clear) or xy-z (set xy, clear z). The flags are: 57 58 i case-insensitive (default false) 59 m multi-line mode: ^ and $ match begin/end line in addition to begin/end text (default false) 60 s let . match \n (default false) 61 U ungreedy: swap meaning of x* and x*?, x+ and x+?, etc (default false) 62 63 Empty strings: 64 ^ at beginning of text or line (flag m=true) 65 $ at end of text (like \z not \Z) or line (flag m=true) 66 \A at beginning of text 67 \b at ASCII word boundary (\w on one side and \W, \A, or \z on the other) 68 \B not an ASCII word boundary 69 \z at end of text 70 71 Escape sequences: 72 \a bell (== \007) 73 \f form feed (== \014) 74 \t horizontal tab (== \011) 75 \n newline (== \012) 76 \r carriage return (== \015) 77 \v vertical tab character (== \013) 78 \* literal *, for any punctuation character * 79 \123 octal character code (up to three digits) 80 \x7F hex character code (exactly two digits) 81 \x{10FFFF} hex character code 82 \Q...\E literal text ... even if ... has punctuation 83 84 Character class elements: 85 x single character 86 A-Z character range (inclusive) 87 \d Perl character class 88 [:foo:] ASCII character class foo 89 \p{Foo} Unicode character class Foo 90 \pF Unicode character class F (one-letter name) 91 92 Named character classes as character class elements: 93 [\d] digits (== \d) 94 [^\d] not digits (== \D) 95 [\D] not digits (== \D) 96 [^\D] not not digits (== \d) 97 [[:name:]] named ASCII class inside character class (== [:name:]) 98 [^[:name:]] named ASCII class inside negated character class (== [:^name:]) 99 [\p{Name}] named Unicode property inside character class (== \p{Name}) 100 [^\p{Name}] named Unicode property inside negated character class (== \P{Name}) 101 102 Perl character classes: 103 \d digits (== [0-9]) 104 \D not digits (== [^0-9]) 105 \s whitespace (== [\t\n\f\r ]) 106 \S not whitespace (== [^\t\n\f\r ]) 107 \w ASCII word characters (== [0-9A-Za-z_]) 108 \W not ASCII word characters (== [^0-9A-Za-z_]) 109 110 ASCII character classes: 111 [:alnum:] alphanumeric (== [0-9A-Za-z]) 112 [:alpha:] alphabetic (== [A-Za-z]) 113 [:ascii:] ASCII (== [\x00-\x7F]) 114 [:blank:] blank (== [\t ]) 115 [:cntrl:] control (== [\x00-\x1F\x7F]) 116 [:digit:] digits (== [0-9]) 117 [:graph:] graphical (== [!-~] == [A-Za-z0-9!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~]) 118 [:lower:] lower case (== [a-z]) 119 [:print:] printable (== [ -~] == [ [:graph:]]) 120 [:punct:] punctuation (== [!-/:-@[-`{-~]) 121 [:space:] whitespace (== [\t\n\v\f\r ]) 122 [:upper:] upper case (== [A-Z]) 123 [:word:] word characters (== [0-9A-Za-z_]) 124 [:xdigit:] hex digit (== [0-9A-Fa-f]) 125 126 */ 127 package syntax