Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.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 manual >> 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')
<< 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:
Wed Jan 26 16:25:13 CET 2011