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.

110 lines
4.6 KiB

  1. .TH PCRE2_SUBSTITUTE 3 "22 January 2020" "PCRE2 10.35"
  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 int pcre2_substitute(const pcre2_code *\fIcode\fP, PCRE2_SPTR \fIsubject\fP,
  11. .B " PCRE2_SIZE \fIlength\fP, PCRE2_SIZE \fIstartoffset\fP,"
  12. .B " uint32_t \fIoptions\fP, pcre2_match_data *\fImatch_data\fP,"
  13. .B " pcre2_match_context *\fImcontext\fP, PCRE2_SPTR \fIreplacement\fP,"
  14. .B " PCRE2_SIZE \fIrlength\fP, PCRE2_UCHAR *\fIoutputbuffer\fP,"
  15. .B " PCRE2_SIZE *\fIoutlengthptr\fP);"
  16. .fi
  17. .
  18. .SH DESCRIPTION
  19. .rs
  20. .sp
  21. This function matches a compiled regular expression against a given subject
  22. string, using a matching algorithm that is similar to Perl's. It then makes a
  23. copy of the subject, substituting a replacement string for what was matched.
  24. Its arguments are:
  25. .sp
  26. \fIcode\fP Points to the compiled pattern
  27. \fIsubject\fP Points to the subject string
  28. \fIlength\fP Length of the subject string
  29. \fIstartoffset\fP Offset in the subject at which to start matching
  30. \fIoptions\fP Option bits
  31. \fImatch_data\fP Points to a match data block, or is NULL
  32. \fImcontext\fP Points to a match context, or is NULL
  33. \fIreplacement\fP Points to the replacement string
  34. \fIrlength\fP Length of the replacement string
  35. \fIoutputbuffer\fP Points to the output buffer
  36. \fIoutlengthptr\fP Points to the length of the output buffer
  37. .sp
  38. A match data block is needed only if you want to inspect the data from the
  39. final match that is returned in that block or if PCRE2_SUBSTITUTE_MATCHED is
  40. set. A match context is needed only if you want to:
  41. .sp
  42. Set up a callout function
  43. Set a matching offset limit
  44. Change the backtracking match limit
  45. Change the backtracking depth limit
  46. Set custom memory management in the match context
  47. .sp
  48. The \fIlength\fP, \fIstartoffset\fP and \fIrlength\fP values are code units,
  49. not characters, as is the contents of the variable pointed at by
  50. \fIoutlengthptr\fP. This variable must contain the length of the output buffer
  51. when the function is called. If the function is successful, the value is
  52. changed to the length of the new string, excluding the trailing zero that is
  53. automatically added.
  54. .P
  55. The subject and replacement lengths can be given as PCRE2_ZERO_TERMINATED for
  56. zero-terminated strings. The options are:
  57. .sp
  58. PCRE2_ANCHORED Match only at the first position
  59. PCRE2_ENDANCHORED Match only at end of subject
  60. .\" JOIN
  61. PCRE2_NOTBOL Subject is not the beginning of a
  62. line
  63. PCRE2_NOTEOL Subject is not the end of a line
  64. .\" JOIN
  65. PCRE2_NOTEMPTY An empty string is not a
  66. valid match
  67. .\" JOIN
  68. PCRE2_NOTEMPTY_ATSTART An empty string at the start of
  69. the subject is not a valid match
  70. PCRE2_NO_JIT Do not use JIT matching
  71. .\" JOIN
  72. PCRE2_NO_UTF_CHECK Do not check for UTF validity in
  73. the subject or replacement
  74. .\" JOIN
  75. (only relevant if PCRE2_UTF was
  76. set at compile time)
  77. PCRE2_SUBSTITUTE_EXTENDED Do extended replacement processing
  78. .\" JOIN
  79. PCRE2_SUBSTITUTE_GLOBAL Replace all occurrences in the
  80. subject
  81. PCRE2_SUBSTITUTE_LITERAL The replacement string is literal
  82. .\" JOIN
  83. PCRE2_SUBSTITUTE_MATCHED Use pre-existing match data for
  84. first match
  85. PCRE2_SUBSTITUTE_OVERFLOW_LENGTH If overflow, compute needed length
  86. PCRE2_SUBSTITUTE_REPLACEMENT_ONLY Return only replacement string(s)
  87. PCRE2_SUBSTITUTE_UNKNOWN_UNSET Treat unknown group as unset
  88. PCRE2_SUBSTITUTE_UNSET_EMPTY Simple unset insert = empty string
  89. .sp
  90. If PCRE2_SUBSTITUTE_LITERAL is set, PCRE2_SUBSTITUTE_EXTENDED,
  91. PCRE2_SUBSTITUTE_UNKNOWN_UNSET, and PCRE2_SUBSTITUTE_UNSET_EMPTY are ignored.
  92. .P
  93. If PCRE2_SUBSTITUTE_MATCHED is set, \fImatch_data\fP must be non-NULL; its
  94. contents must be the result of a call to \fBpcre2_match()\fP using the same
  95. pattern and subject.
  96. .P
  97. The function returns the number of substitutions, which may be zero if there
  98. are no matches. The result may be greater than one only when
  99. PCRE2_SUBSTITUTE_GLOBAL is set. In the event of an error, a negative error code
  100. is returned.
  101. .P
  102. There is a complete description of the PCRE2 native API in the
  103. .\" HREF
  104. \fBpcre2api\fP
  105. .\"
  106. page and a description of the POSIX API in the
  107. .\" HREF
  108. \fBpcre2posix\fP
  109. .\"
  110. page.