Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.0 - 日本語

Change language to:
English - Français - Português - Русский

Please note that the recommended version of Scilab is 2024.0.0. This page might be outdated.
See the recommended documentation of this function

Scilabヘルプ >> Strings > strindex

strindex

他の文字列の中で指定した文字列の位置を探す.

呼び出し手順

ind = strindex(haystack, needle, [flag])

[ind, which] = strindex(haystack, needle, [flag])

引数

haystack

文字列. needleが現れる場所を探す文字列

needle

文字列または文字列ベクトル. haystackで探す文字列

ind

添字のベクトル

which

添字のベクトル

flag

文字列("r"の場合は正規表現)

説明

strindexは, haystackの中でneedle(i)が 見つかる場所のインデックスを探します.

kに関して, part(haystack,ind(k)+(0:length(needle(i))-1))needle(i)と同じ文字列となるよな iが存在します. which引数が必要な場合, これにはこれらのiが含まれる必要があります. 3番目のパラメータ"r"を指定する場合, needleは正規表現の文字列とする必要があります. この場合, strindexは正規表現式の規則に基づき haystackを検索します.

正規表現式引数を指定しないstrindexは Knuth-Morris-Prattアルゴリズムに基づきます.

このアルゴリズムは Scilab 4.x で使用されるものよりも より強力です. いくつかの特殊なケースでは,結果が異なることがあります.

例:

// Scilab 5.x

-->[k,w]=strindex('aab',['a','ab'])

w = 1. 1. 2. k = 1. 2. 2.

// Scilab 4.x

-->[k,w]=strindex('aab',['a','ab'])

w = 1. 1. k = 1. 2.

正規表現の規則はPerl言語に似ていますT. 使い始めるには, http://perldoc.perl.org/perlrequick.htmlを参照してください. より詳細なチュートリアルについては http://perldoc.perl.org/perlretut.html を参照ください. リファレンスについては, http://perldoc.perl.org/perlre.html を参照してください

k=strindex('SCI/demos/scicos','/')
k=strindex('SCI/demos/scicos','SCI/')
k=strindex('SCI/demos/scicos','!')
k=strindex('aaaaa','aa')
k=strindex('SCI/demos/scicos',['SCI','sci'])
[k,w]=strindex('1+3*abc/2.33',['+','-','*','/'])
k=strindex('2' ,'/2(]*)?$\1/' ,'r')

参照

  • string — 文字列に変換
  • strings — Scilabオブジェクト, 文字列
  • regexp — 正規表現文字列に一致する部分文字列を探す
  • strsubst — 文字列を他の文字列で置換する.
Report an issue
<< strcspn Strings string >>

Copyright (c) 2022-2023 (Dassault Systèmes)
Copyright (c) 2017-2022 (ESI Group)
Copyright (c) 2011-2017 (Scilab Enterprises)
Copyright (c) 1989-2012 (INRIA)
Copyright (c) 1989-2007 (ENPC)
with contributors
Last updated:
Tue Feb 25 08:53:23 CET 2020