无涯教程-JavaScript - SEARCH函数

83 阅读1分钟

描述

SEARCH和SEARCHB函数将一个文本字符串定位在第二个文本字符串中,并从第二个文本字符串的第一个字符返回第一个文本字符串的起始位置的编号。

仅当将DBCS语言设置为默认语言时,SEARCHB才计算每个字符2个字节。否则SEARCHB的行为与SEARCH相同,每个字符计数1个字节。

支持DBCS的语言包括日语,中文(简体),中文(繁体)和韩语。

语法

SEARCH (find_text,within_text,[start_num]) 
SEARCHB (find_text,within_text,[start_num]) 

争论

Argument 描述 Required/Optional
find_text The text that you want to find. Required
within_text The text in which you want to search for the value of the find_text argument. Required
start_num The character number in the within_text argument at which you want to start searching. Optional

Notes

  • SEARCH和SEARCHB函数不区分大小写。如果要进行区分大小写的搜索,则可以使用FIND和FINDB。

  • 您可以在find_text参数中使用通配符问号(?)和星号(*)。问号与任何单个字符匹配;星号匹配任何字符序列。如果要查找实际的问号或星号,请在字符前键入波浪号(〜)。

  • 如果省略了start_num参数,则假定为1。

  • 如果未找到find_text的值,则为#VALUE!返回错误值。

  • 如果start_num不大于0(零)或大于inner_text参数的长度,则为#VALUE!返回错误值。

适用性

Excel 2007,Excel 2010,Excel 2013,Excel 2016

Example

SEARCH Function

参考链接

www.learnfk.com/javascript/…