/scilab-master-1333395999/modules/string/help/pt_BR/strindex.xml

# · XML · 134 lines · 123 code · 0 blank · 11 comment · 0 complexity · 0c8b1c800ca10bced9eb658a45bf2fad MD5 · raw file

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  4. * Copyright (C) INRIA -
  5. *
  6. * This file must be used under the terms of the CeCILL.
  7. * This source file is licensed as described in the file COPYING, which
  8. * you should have received as part of this distribution. The terms
  9. * are also available at
  10. * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
  11. *
  12. -->
  13. <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab" xml:id="strindex" xml:lang="en">
  14. <info>
  15. <pubdate>$LastChangedDate: 2008-01-06 16:57:13 +0200 (Mon, 06 Febrary
  16. 2008)$
  17. </pubdate>
  18. </info>
  19. <refnamediv>
  20. <refname>strindex</refname>
  21. <refpurpose>procura posição de um string em outro</refpurpose>
  22. </refnamediv>
  23. <refsynopsisdiv>
  24. <title>Seqüência de Chamamento</title>
  25. <synopsis>ind=strindex(haystack,needle,[flag])
  26. [ind,which]=strindex(haystack,needle,[flag])
  27. </synopsis>
  28. </refsynopsisdiv>
  29. <refsection>
  30. <title>Parâmetros</title>
  31. <variablelist>
  32. <varlistentry>
  33. <term>haystack</term>
  34. <listitem>
  35. <para>string. O string onde se procurará por ocorrências de
  36. <literal>needle </literal>
  37. </para>
  38. </listitem>
  39. </varlistentry>
  40. <varlistentry>
  41. <term>needle</term>
  42. <listitem>
  43. <para>string ou vetor de strings . O(s) string(s) a serem procurados
  44. em <literal>haystack</literal>
  45. </para>
  46. </listitem>
  47. </varlistentry>
  48. <varlistentry>
  49. <term>ind</term>
  50. <listitem>
  51. <para>vetor de índices</para>
  52. </listitem>
  53. </varlistentry>
  54. <varlistentry>
  55. <term>which</term>
  56. <listitem>
  57. <para>vetor de índices</para>
  58. </listitem>
  59. </varlistentry>
  60. <varlistentry>
  61. <term>flag</term>
  62. <listitem>
  63. <para>string ("r" para expressão regular)</para>
  64. </listitem>
  65. </varlistentry>
  66. </variablelist>
  67. </refsection>
  68. <refsection>
  69. <title>Descrição</title>
  70. <para>
  71. <literal>strindex</literal> procura índices onde <literal>needle
  72. (i)
  73. </literal>
  74. é encontrado em <literal>haystack</literal>
  75. </para>
  76. <para>
  77. Para cada <literal>k</literal> existe um <literal>i</literal> tal
  78. que <literal>part(haystack,ind(k)+(0:length(needle(i))-1))</literal> é o
  79. mesmo string que <literal>needle(i)</literal>. Se o argumento
  80. <literal>which</literal> for requerido, ele contém esses
  81. <literal>i</literal>. Quando se usa o terceiro parâmetro "r", needle deve
  82. ser um string de expressão regular. Então, strindex irá corresponder a
  83. haystack de acordo com as regras regulares expressas.
  84. </para>
  85. <para>
  86. <literal>strindex</literal> sem expressão regular é baseado no
  87. algoritmo de Knuth-Morris-Pratt.
  88. </para>
  89. <para>Este algoritmo é mais poderoso que aquele usado no Scilab 4.x. Em
  90. alguns casos especiais, o resultado pode ser diferente.
  91. </para>
  92. <para>Exemplo:</para>
  93. <para>// Scilab 5.x</para>
  94. <para>--&gt;[k,w]=strindex('aab',['a','ab'])</para>
  95. <para>w = 1. 1. 2. k = 1. 2. 2.</para>
  96. <para>// scilab 4.x</para>
  97. <para>--&gt;[k,w]=strindex('aab',['a','ab'])</para>
  98. <para>w = 1. 1. k = 1. 2.</para>
  99. <para>As regras de expressão regular são similares às da linguagem Perl.
  100. Para uma introdução rápida , ver <ulink url="http://perldoc.perl.org/perlrequick.html">http://perldoc.perl.org/perlrequick.html</ulink>.
  101. Para um tutorial mais profundo , ver <ulink url="http://perldoc.perl.org/perlretut.html">http://perldoc.perl.org/perlretut.html</ulink>
  102. e para a página de referência, ver <ulink url="http://perldoc.perl.org/perlre.html">http://perldoc.perl.org/perlre.html</ulink>
  103. </para>
  104. </refsection>
  105. <refsection>
  106. <title>Exemplos</title>
  107. <programlisting role="example"><![CDATA[
  108. k=strindex('SCI/demos/scicos','/')
  109. k=strindex('SCI/demos/scicos','SCI/')
  110. k=strindex('SCI/demos/scicos','!')
  111. k=strindex('aaaaa','aa')
  112. k=strindex('SCI/demos/scicos',['SCI','sci'])
  113. [k,w]=strindex('1+3*abc/2.33',['+','-','*','/'])
  114. k=strindex('2' ,'/2(]*)?$\1/' ,'r')
  115. ]]></programlisting>
  116. </refsection>
  117. <refsection>
  118. <title>Ver Também</title>
  119. <simplelist type="inline">
  120. <member>
  121. <link linkend="string">string</link>
  122. </member>
  123. <member>
  124. <link linkend="strings">strings</link>
  125. </member>
  126. <member>
  127. <link linkend="regexp">regexp</link>
  128. </member>
  129. <member>
  130. <link linkend="strsubst">strsubst</link>
  131. </member>
  132. </simplelist>
  133. </refsection>
  134. </refentry>