1 <?xml version="1.0" encoding="UTF-8"?>
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) INRIA -
5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
16 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml"
18 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
19 xml:id="strspn" xml:lang="en">
21 <refname>strspn</refname>
23 lengths of the beginning of strings as long as characters are among those allowed
28 <synopsis>headsLengths = strspn(Strings, allowedChars)</synopsis>
31 <title>Arguments</title>
34 <term>Strings, allowedChars, headsLengths</term>
37 Matrices of strings, of identical dimensions.
38 <varname>allowedChars</varname> can be a scalar string.
39 It is then used for all <varname>Strings</varname> components.
46 <title>Description</title>
48 <literal>headsLengths = strspn(Strings, allowedChars)</literal> returns the length of the initial
49 portion of <varname>Strings</varname> which consists only of characters that are part of
50 <varname>allowedChars</varname>.
54 <title>Examples</title>
55 <programlisting role="example"><![CDATA[
57 strspn("129th or the 130th", allowed)
59 t = ["characters" "matrix" ; "text" "strings"]
63 allowed = ["a":"j", "a":"u" ; "d":"u", "g":"v"]
71 --> strspn("129th or the 130th", allowed)
76 --> t = ["characters" "matrix" ; "text" "strings"]
84 --> strspn(t, allowed)
89 --> allowed = ["a":"j", "a":"u" ; "d":"u", "g":"v"]
91 "abcdefghij" "abcdefghijklmnopqrstu"
92 "defghijklmnopqrstu" "ghijklmnopqrstuv"
94 --> strspn(t, allowed)
100 With UTF-8 extended characters:
102 <programlisting role="example"><![CDATA[
103 t = "Να αμφιβάλλετε τα πάντα ή να μην αμφιβάλλετε τίποτα: " + ..
104 "δύο ίσοι τρόποι αποφυγής σκέψης.";
105 t = matrix(strsplit(t," "), 2,-1)
106 allowed = "Ναβγδεϵζηθικλμνξοπρστυφϕχψωϐϑϰϱςϖ";
110 --> t = matrix(strsplit(t," "), 2,-1)
112 "Να" "τα" "ή" "μην" "τίποτα:" "ίσοι" "αποφυγής"
113 "αμφιβάλλετε" "πάντα" "να" "αμφιβάλλετε" "δύο" "τρόποι" "σκέψης."
115 --> allowed = "Ναβγδεϵζηθικλμνξοπρστυφϕχψωϐϑϰϱςϖ";
116 --> strspn(t, allowed)
122 <refsection role="see also">
123 <title>See also</title>
124 <simplelist type="inline">
126 <link linkend="strcspn">strcspn</link>
129 <link linkend="strncpy">strncpy</link>
132 <link linkend="part">part</link>