문자열에서 배열에 지정된 항목을 검색하고 문자열에 있는 첫 번째 항목의 배열에서 위치를 반환합니다.
구문
has_any_index
(
원본,값)
구문 규칙에 대해 자세히 알아봅니다.
매개 변수
| 이름 | 유형 | 필수 | 설명 |
|---|---|---|---|
| 원본 | string |
✔️ | 검색할 값입니다. |
| 값 | dynamic |
✔️ | 조회할 스칼라 또는 리터럴 식의 배열입니다. |
반품
원본에 있는 값에서 첫 번째 항목의 인덱스 위치(0부터 시작)입니다. 문자열에 배열 항목이 없거나 값이 비어 있으면 -1을 반환합니다.
예시
다음 예제에서는 쉼표로 구분된 스칼라 값 집합과 함께 사용하는 has_any_index 방법을 보여 있습니다.
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 |