- Ajuda do Scilab
- Cadeias de Caracteres (Strings)
- ascii
- blanks
- char
- convstr
- emptystr
- eval
- evstr
- grep
- isalphanum
- isascii
- isdigit
- isletter
- isnum
- justify
- length
- part
- regexp
- sci2exp
- strcat
- strchr
- strcmp
- strcmpi
- strcspn
- strindex
- string
- strings
- stripblanks
- strncpy
- strrchr
- strrev
- strsplit
- strspn
- strstr
- strsubst
- strtod
- strtok
- tokenpos
- tokens
- asciimat
strindex
procura posição de um string em outro
Seqüência de Chamamento
ind=strindex(haystack,needle,[flag]) [ind,which]=strindex(haystack,needle,[flag])
Parâmetros
- haystack
string. O string onde se procurará por ocorrências de
needle
- needle
string ou vetor de strings . O(s) string(s) a serem procurados em
haystack
- ind
vetor de índices
- which
vetor de índices
- flag
string ("r" para expressão regular)
Descrição
strindex
procura índices onde needle
(i)
é encontrado em haystack
Para cada k
existe um i
tal
que part(haystack,ind(k)+(0:length(needle(i))-1))
é o
mesmo string que needle(i)
. Se o argumento
which
for requerido, ele contém esses
i
. Quando se usa o terceiro parâmetro "r", needle deve
ser um string de expressão regular. Então, strindex irá corresponder a
haystack de acordo com as regras regulares expressas.
strindex
sem expressão regular é baseado no
algoritmo de Knuth-Morris-Pratt.
Este algoritmo é mais poderoso que aquele usado no Scilab 4.x. Em alguns casos especiais, o resultado pode ser diferente.
Exemplo:
// 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.
As regras de expressão regular são similares às da linguagem Perl. Para uma introdução rápida , ver http://perldoc.perl.org/perlrequick.html. Para um tutorial mais profundo , ver http://perldoc.perl.org/perlretut.html e para a página de referência, ver http://perldoc.perl.org/perlre.html
Exemplos
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')
Comments
Add a comment:
Please login to comment this page.