Clarify offset parameter behavior in RegEx methods

This commit is contained in:
Haoyu Qiu 2022-11-01 09:23:10 +08:00
parent c29fe310f1
commit 3b88851e25

View file

@ -99,7 +99,8 @@
<param index="1" name="offset" type="int" default="0" /> <param index="1" name="offset" type="int" default="0" />
<param index="2" name="end" type="int" default="-1" /> <param index="2" name="end" type="int" default="-1" />
<description> <description>
Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise [code]null[/code]. The region to search within can be specified without modifying where the start and end anchor would be. Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise [code]null[/code].
The region to search within can be specified with [param offset] and [param end]. This is useful when searching for another match in the same [param subject] by calling this method again after a previous success. Note that setting these parameters differs from passing over a shortened string. For example, the start anchor [code]^[/code] is not affected by [param offset], and the character before [param offset] will be checked for the word boundary [code]\b[/code].
</description> </description>
</method> </method>
<method name="search_all" qualifiers="const"> <method name="search_all" qualifiers="const">
@ -108,7 +109,8 @@
<param index="1" name="offset" type="int" default="0" /> <param index="1" name="offset" type="int" default="0" />
<param index="2" name="end" type="int" default="-1" /> <param index="2" name="end" type="int" default="-1" />
<description> <description>
Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found, an empty array is returned instead. The region to search within can be specified without modifying where the start and end anchor would be. Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found, an empty array is returned instead.
The region to search within can be specified with [param offset] and [param end]. This is useful when searching for another match in the same [param subject] by calling this method again after a previous success. Note that setting these parameters differs from passing over a shortened string. For example, the start anchor [code]^[/code] is not affected by [param offset], and the character before [param offset] will be checked for the word boundary [code]\b[/code].
</description> </description>
</method> </method>
<method name="sub" qualifiers="const"> <method name="sub" qualifiers="const">
@ -119,7 +121,8 @@
<param index="3" name="offset" type="int" default="0" /> <param index="3" name="offset" type="int" default="0" />
<param index="4" name="end" type="int" default="-1" /> <param index="4" name="end" type="int" default="-1" />
<description> <description>
Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are expanded and resolved. By default, only the first instance is replaced, but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be. Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]$1[/code] and [code]$name[/code] are expanded and resolved. By default, only the first instance is replaced, but it can be changed for all instances (global replacement).
The region to search within can be specified with [param offset] and [param end]. This is useful when searching for another match in the same [param subject] by calling this method again after a previous success. Note that setting these parameters differs from passing over a shortened string. For example, the start anchor [code]^[/code] is not affected by [param offset], and the character before [param offset] will be checked for the word boundary [code]\b[/code].
</description> </description>
</method> </method>
</methods> </methods>