ABAP_SYNTAX 1. ... find( val = text> ${ sub = substring> $}$|${pcre = regex>$} $[ case = case>$] $[off = off>$] $[ len = len>$] $[ occ = occ>$] ) ...> 2. ... find_end( val = text> ${ sub = substring> $}$|${pcre = regex>$} $[ case = case>$] $[off = off>$] $[ len = len>$] $[ occ = occ>$] ) ...> 3. ... find_any_of( val = text> sub = substring> $[off = off>$] $[ len = len>$] $[ occ = occ>$] ) ...> 4. ... find_any_not_of( val = text> sub = substring> $[off = off> $] $[len = len>$] $[ occ = occ>$] ) ...>
What does it do? The built-in> search functions find> and find_...> search text>> for the characters specified in substring>> or for a match with a regular expression> specified in regex> >, where the optional parameters off>> and len>> determine the subarea to be searched and the occurrence of the match can be specified in the optional parameter occ>>. If the argument pcre> is used, regex> must contain a PCRE regular expression>. A regular expression in PCRE syntax is compiled in an extended mode: Most unescaped whitespace (blanks and line breaks) of the pattern are ignored outside character classes and comments can be placed behind #>. In order to include whitespace and #> into a pattern, they must be escaped or the extended mode must be switched of with (?-x)>> in the regular expression. The return value has the type i> and is filled as follows:
The function find> searches for the exact substring specified in substring>> or for a match with the regular expression regex>> and returns the offset of the occurrence with respect to the entire length of text>. The search is case-sensitive by default, but this can be overridden using the parameter case>>. If substring> is empty, an exception from the class CX_SY_STRG_PAR_VAL> is raised.
The function find_end> searches like find>, but it returns the sum of the offset of the occurrence and the length of the found match with the regular expression.
The function find_any_of> returns the offset of the occurrence of any character contained in substring >>, and is always case-sensitive. If substring> is empty, the value -1 is returned.
The function find_any_not_of> returns the offset of the found occurrence of any character not in substring>>, and is always case-sensitive. If substring> is empty, the value -1 is returned. If a search is not successful, all functions return the value -1. The optional parameters off>> , len>>, and occ>> have the following meaning when combined:
If occ> is positive, the subarea defined by off> and len > is searched from left to right.
If occ> is negative, the subarea defined by off> and len > is searched from right to left. The occurrence of the match specified by occ> refers to the search range defined by off> and len>.
Latest notes:
Using the related search functions count>> and count_...>>, it is possible to determine the total number of occurrences instead of an offset.
Like the statement FIND>>, the search functions can be faster than the comparison operator CS>> by some magnitude.
Besides pcre>, also the obsolete argument regex >> can be used. Then an obsolete POSIX regular expression> must be passed. BEGIN_SECTION SAP_INTERNAL_HINT The restriction of the arguments to functional operand positions instead of expression positions (as it is for most other string functions) stems from the fact that find is evaluated on the compute stack. END_SECTION SAP_INTERNAL_HINT NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 The result of the following function calls is 3, 6, 3, and 3. ABEXA 01235 ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA String Functions, find> and substring>> ABAP_EXAMPLE_END
Runtime Exceptions
Catchable Exceptions CX_SY_RANGE_OUT_OF_BOUNDS>>
Reason for error:
Illegal offset or length specified in off> and len>.