Related Topics: | ||
Description: Returns the number of the character at which a specific character or text string is first found, reading from left to right. SEARCH is not case sensitive and can include wildcard characters.
SEARCH is intended for use with languages that use the single-byte character set (SBCS). SEARCH always counts each character, whether single-byte or double-byte, as 1, no matter what the default language setting is.
Syntax: SEARCH(Find_text, Within_text, [Start_num])
Find_text is the text you want to find.
Within_text is the text in which you want to search for Find_text.
Start_num is the character number in Within_text at which you want to start searching.
Remarks:
Use SEARCH to determine the location of a character or text string within another text string so that you can use the MID or REPLACE functions to change the text.
SEARCH is not case sensitive. If you want to do a case sensitive search, you can use FIND.
You can use the wildcard characters, question mark (?) and asterisk (*), in Find_text. A question mark matches any single character; an asterisk matches any sequence of characters. If you want to find an actual question mark or asterisk, type a tilde (~) before the character.
If Find_text is not found, the #VALUE! error value is returned.
If Start_num is omitted, it is assumed to be 1.
Start_num must be greater than 0 (zero) and less than or equal to the length of Within_text.
Use Start_num to skip a specified number of characters. Using SEARCH as an example, suppose you are working with the text string "AYF0093.YoungMensApparel". To find the number of the first "Y" in the descriptive part of the text string, set Start_num equal to 8 so that the serial-number portion of the text is not searched. SEARCH begins with character 8, finds Find_text at the next character and returns the number 9. SEARCH always returns the number of characters from the start of Within_text, counting the characters you skip if Start_num is greater than 1.
Example:
SEARCH("e", "Statements", 6) = 7 (position of the first "e" in the first string above, starting at the sixth position)
SEARCH("margin", "Profit Margin") = 8 (position of "margin" in "Profit Margin")
REPLACE("Profit Margin", SEARCH("margin", "Profit Margin"), 6, "Amount") = Profit Amount (replaces "Margin" with "Amount")
In the following example, SEARCH returns 2 because "" is in the second position within the string.
SEARCH("", "") = 2
© 1992-2015. ReliaSoft Corporation. ALL RIGHTS RESERVED.