has_any_index()
搜索字符串以查找数组中的指定项,然后返回在字符串中找到的第一个项在数组中的位置。 has_any_index
搜索关键词,一个索引词包含三个或三个以上字符。 如果词少于三个字符,则查询会扫描列中的值,这比在关键词中查找词要慢。
语法
has_any_index
(
source,
values)
详细了解语法约定。
参数
客户 | 类型 | 必需 | 说明 |
---|---|---|---|
source | string |
✔ | 要搜索的值。 |
值 | dynamic |
✔ | 要查找的标量或文本表达式的数组。 |
返回
在 source 中找到的 values 中第一个项的索引位置(从零开始)。 如果在 string 中未找到任何数组项或 values 为空,则返回 -1。
示例
print
idx1 = has_any_index("this is an example", dynamic(['this', 'example'])) // first lookup found in input string
, idx2 = has_any_index("this is an example", dynamic(['not', 'example'])) // last lookup found in input string
, idx3 = has_any_index("this is an example", dynamic(['not', 'found'])) // no lookup found in input string
, idx4 = has_any_index("Example number 2", range(1, 3, 1)) // Lookup array of integers
, idx5 = has_any_index("this is an example", dynamic([])) // Empty lookup array
输出
idx1 | idx2 | idx3 | idx4 | idx5 |
---|---|---|---|---|
0 | 1 | -1 | 1 | -1 |