Difference between revisions of "Documentation/How Tos/Calc: FIND function"
From Apache OpenOffice Wiki
< Documentation | How Tos
GreatBigBore (Talk | contribs) (Indicated that the function does not use regex; referred to SEARCH() for case-insensitive and regex searching; added note for =/<> setting, to be consistent with SEARCH() documentation) |
m |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{DISPLAYTITLE:FIND function}} |
− | + | {{Documentation/CalcFunc TextTOC | |
− | + | |ShowPrevNext=block | |
− | + | |PrevPage=Documentation/How_Tos/Calc:_EXACT_function | |
− | | | + | |NextPage=Documentation/How_Tos/Calc:_FIXED_function |
− | + | }}__NOTOC__ | |
− | | | + | |
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== FIND == | == FIND == | ||
Returns the position of a string of text within another string. | Returns the position of a string of text within another string. | ||
Line 43: | Line 15: | ||
: <tt>'''startposition'''</tt> (optional) is the position from which the search starts. | : <tt>'''startposition'''</tt> (optional) is the position from which the search starts. | ||
− | : The search is case-sensitive. For case-insensitive search, see '''SEARCH()''' | + | : The search is case-sensitive. For case-insensitive search, see '''SEARCH()'''. |
− | : The search will '''not''' use regular expressions. For searching with regular expressions, see '''SEARCH()''' | + | : The search will '''not''' use regular expressions. For searching with regular expressions, see '''SEARCH()'''. |
: A failed search gives the <tt>'''#VALUE!'''</tt> error. | : A failed search gives the <tt>'''#VALUE!'''</tt> error. | ||
Line 53: | Line 25: | ||
=== Example: === | === Example: === | ||
<tt>'''FIND("yo"; "Yoyo")'''</tt> | <tt>'''FIND("yo"; "Yoyo")'''</tt> | ||
− | : returns <tt>'''3'''</tt>. | + | : returns <tt>'''3'''</tt>. The search is case-sensitive. |
<tt>'''FIND("cho"; "choochoo"; 2)'''</tt> | <tt>'''FIND("cho"; "choochoo"; 2)'''</tt> | ||
Line 67: | Line 39: | ||
:: <tt>'''IF( ISNUMBER( FIND("xyz","abcdef",1) ) , "Substring Present", "ERR: Missing Substring" )'''</tt>. | :: <tt>'''IF( ISNUMBER( FIND("xyz","abcdef",1) ) , "Substring Present", "ERR: Missing Substring" )'''</tt>. | ||
::: returns <tt>'''"ERR: Missing Substring"'''</tt> (... allowing the IF() to function, and not propagating the error from the FIND() function. | ::: returns <tt>'''"ERR: Missing Substring"'''</tt> (... allowing the IF() to function, and not propagating the error from the FIND() function. | ||
− | :: NOTE: In practice, it may be more maintainable to use ISNUMBER() to avoid negative logic, and it is more | + | :: NOTE: In practice, it may be more maintainable to use ISNUMBER() to avoid negative logic, and it is more indicative of the evaluation desired: if the substring has a position, then ISNUMBER() is TRUE, else ISNUMBER() is FALSE. |
− | {{ | + | {{SeeAlso|EN| |
* [[Documentation/How_Tos/Calc: REPLACE function|REPLACE]] | * [[Documentation/How_Tos/Calc: REPLACE function|REPLACE]] | ||
* [[Documentation/How_Tos/Calc: SEARCH function|SEARCH]] | * [[Documentation/How_Tos/Calc: SEARCH function|SEARCH]] |