Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
5.3.2 - Português

Change language to:
English - Français - 日本語 -

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

Ajuda Scilab >> Cadeias de Caracteres (Strings) > grep

grep

acha correspondências de um string em um vetor de strings

Seqüência de Chamamento

row=grep(haystack,needle )
[row,which]=grep(haystack,needle )
row=grep(haystack,needle ,[flag])
[row,which]=grep(haystack,needle ,[flag])

Parâmetros

haystack

vetor linha de strings

needle

string ou vetor linha de strings . O(s) string(s) a serem procurados em haystack.

row

vetor de índices: linha onde uma correspondência foi encontrada, ou matriz vazia se nenhuma ocorrência tiver sido encontrada

which

vetor de índices: índice do string needle encontrado, ou uma matriz vazia, se nenhuma correspondência tiver sido encontrada

flag

caractere ("r" para expressão regular)

Descrição

Para cada entradada de haystack , grep procura se pelo menos um string em needle corresponde a um substring. Os índices das entradas de haystack onde pelo menos uma entrada foi encontrada são retornados no argumento row. O argumento opcional which fornece o índice do primeiro string de needle encontrado. Quando se usa o terceiro parâmetro "r", needle deve ser substituído por uma expressão regular. Então, grep vai corresponder a haystack de acordo com as regras regulares expressas.

Exemplos

txt=['acha correspondência em um string ou em um vetor de strings'
     'procura posição de um string em outro string'
     'Compara Strings'];

grep(txt,'strings')
grep(txt,['strings' 'Strings'])

[r,w]=grep(txt,['strings' 'Strings'])

str = ["hat";"cat";"hhat";"chat";"hcat";"ccchat";"at";"dog"]

grep(str,'/[hc]+at/','r')
grep(str,'/[hc]?at/','r')
grep(str,'/cat|dog/','r')

Ver Também

  • strindex — procura posição de um string em outro
<< evstr Cadeias de Caracteres (Strings) isalphanum >>

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:
Thu May 12 11:45:27 CEST 2011