github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

106 lines
4.5 KiB

  1. .TH PCRE2_COMPILE 3 "19 January 2024" "PCRE2 10.43"
  2. .SH NAME
  3. PCRE2 - Perl-compatible regular expressions (revised API)
  4. .SH SYNOPSIS
  5. .rs
  6. .sp
  7. .B #include <pcre2.h>
  8. .PP
  9. .nf
  10. .B pcre2_code *pcre2_compile(PCRE2_SPTR \fIpattern\fP, PCRE2_SIZE \fIlength\fP,
  11. .B " uint32_t \fIoptions\fP, int *\fIerrorcode\fP, PCRE2_SIZE *\fIerroroffset,\fP"
  12. .B " pcre2_compile_context *\fIccontext\fP);"
  13. .fi
  14. .
  15. .SH DESCRIPTION
  16. .rs
  17. .sp
  18. This function compiles a regular expression pattern into an internal form. Its
  19. arguments are:
  20. .sp
  21. \fIpattern\fP A string containing expression to be compiled
  22. \fIlength\fP The length of the string or PCRE2_ZERO_TERMINATED
  23. \fIoptions\fP Primary option bits
  24. \fIerrorcode\fP Where to put an error code
  25. \fIerroffset\fP Where to put an error offset
  26. \fIccontext\fP Pointer to a compile context or NULL
  27. .sp
  28. The length of the pattern and any error offset that is returned are in code
  29. units, not characters. A NULL pattern with zero length is treated as an empty
  30. string. A compile context is needed only if you want to provide custom memory
  31. allocation functions, or to provide an external function for system stack size
  32. checking (see \fBpcre2_set_compile_recursion_guard()\fP), or to change one or
  33. more of these parameters:
  34. .sp
  35. What \eR matches (Unicode newlines, or CR, LF, CRLF only);
  36. PCRE2's character tables;
  37. The newline character sequence;
  38. The compile time nested parentheses limit;
  39. The maximum pattern length (in code units) that is allowed;
  40. The additional options bits.
  41. .sp
  42. The primary option bits are:
  43. .sp
  44. PCRE2_ANCHORED Force pattern anchoring
  45. PCRE2_ALLOW_EMPTY_CLASS Allow empty classes
  46. PCRE2_ALT_BSUX Alternative handling of \eu, \eU, and \ex
  47. PCRE2_ALT_CIRCUMFLEX Alternative handling of ^ in multiline mode
  48. PCRE2_ALT_VERBNAMES Process backslashes in verb names
  49. PCRE2_AUTO_CALLOUT Compile automatic callouts
  50. PCRE2_CASELESS Do caseless matching
  51. PCRE2_DOLLAR_ENDONLY $ not to match newline at end
  52. PCRE2_DOTALL . matches anything including NL
  53. PCRE2_DUPNAMES Allow duplicate names for subpatterns
  54. PCRE2_ENDANCHORED Pattern can match only at end of subject
  55. PCRE2_EXTENDED Ignore white space and # comments
  56. PCRE2_FIRSTLINE Force matching to be before newline
  57. PCRE2_LITERAL Pattern characters are all literal
  58. PCRE2_MATCH_INVALID_UTF Enable support for matching invalid UTF
  59. PCRE2_MATCH_UNSET_BACKREF Match unset backreferences
  60. PCRE2_MULTILINE ^ and $ match newlines within data
  61. PCRE2_NEVER_BACKSLASH_C Lock out the use of \eC in patterns
  62. PCRE2_NEVER_UCP Lock out PCRE2_UCP, e.g. via (*UCP)
  63. PCRE2_NEVER_UTF Lock out PCRE2_UTF, e.g. via (*UTF)
  64. PCRE2_NO_AUTO_CAPTURE Disable numbered capturing paren-
  65. theses (named ones available)
  66. PCRE2_NO_AUTO_POSSESS Disable auto-possessification
  67. PCRE2_NO_DOTSTAR_ANCHOR Disable automatic anchoring for .*
  68. PCRE2_NO_START_OPTIMIZE Disable match-time start optimizations
  69. PCRE2_NO_UTF_CHECK Do not check the pattern for UTF validity
  70. (only relevant if PCRE2_UTF is set)
  71. PCRE2_UCP Use Unicode properties for \ed, \ew, etc.
  72. PCRE2_UNGREEDY Invert greediness of quantifiers
  73. PCRE2_USE_OFFSET_LIMIT Enable offset limit for unanchored matching
  74. PCRE2_UTF Treat pattern and subjects as UTF strings
  75. .sp
  76. PCRE2 must be built with Unicode support (the default) in order to use
  77. PCRE2_UTF, PCRE2_UCP and related options.
  78. .P
  79. Additional options may be set in the compile context via the
  80. .\" HREF
  81. \fBpcre2_set_compile_extra_options\fP
  82. .\"
  83. function.
  84. .P
  85. If either of \fIerrorcode\fP or \fIerroroffset\fP is NULL, the function returns
  86. NULL immediately. Otherwise, the yield of this function is a pointer to a
  87. private data structure that contains the compiled pattern, or NULL if an error
  88. was detected. In the error case, a text error message can be obtained by
  89. passing the value returned via the \fIerrorcode\fP argument to the
  90. \fBpcre2_get_error_message()\fP function. The offset (in code units) where the
  91. error was encountered is returned via the \fIerroroffset\fP argument.
  92. .P
  93. If there is no error, the value passed via \fIerrorcode\fP returns the message
  94. "no error" if passed to \fBpcre2_get_error_message()\fP, and the value passed
  95. via \fIerroroffset\fP is zero.
  96. .P
  97. There is a complete description of the PCRE2 native API, with more detail on
  98. each option, in the
  99. .\" HREF
  100. \fBpcre2api\fP
  101. .\"
  102. page, and a description of the POSIX API in the
  103. .\" HREF
  104. \fBpcre2posix\fP
  105. .\"
  106. page.