doc.go 5.3 KB

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