Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.1.1 - 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 do Scilab >> Cadeias de Caracteres (Strings) > strspn

strspn

comprimentos do início dos textos, desde que os caracteres estejam entre os permitidos

Seqüência de Chamamento

headsLengths = strspn(Texts, allowedChars)

Parâmetros

Texts, allowedChars, headsLengths

Matrices of texts, of identical dimensions. allowedChars can be a scalar string. It is then used for all Texts components.

Descrição

headsLengths = strspn(Texts,allowedChars) retorna o comprimento da porção inicial de Texts que consiste apenas de caracteres que fazem parte de allowedChars.

Exemplos

allowed = "0":"9"
strspn("129th or the 130th", allowed)

t = ["characters" "matrix" ; "text" "strings"]
allowed = "a":"s"
strspn(t, allowed)

allowed = ["a":"j", "a":"u" ; "d":"u", "g":"v"]
strspn(t, allowed)
--> allowed = "0":"9"
 allowed  =
  "0123456789"

--> strspn("129th or the 130th", allowed)
 ans  =
   3.


--> t = ["characters" "matrix" ; "text" "strings"]
 t  =
  "characters"  "matrix"
  "text"        "strings"

--> allowed = "a":"s"
 allowed  =
  "abcdefghijklmnopqrs"
--> strspn(t, allowed)
 ans  =
   6.   2.
   0.   1.

--> allowed = ["a":"j", "a":"u" ; "d":"u", "g":"v"]
 allowed  =
  "abcdefghij"          "abcdefghijklmnopqrstu"
  "defghijklmnopqrstu"  "ghijklmnopqrstuv"

--> strspn(t, allowed)
 ans  =
   3.   5.
   2.   7.

With UTF-8 extended characters:

t = "Να αμφιβάλλετε τα πάντα ή να μην αμφιβάλλετε τίποτα: " + ..
    "δύο ίσοι τρόποι αποφυγής σκέψης.";
t = matrix(strsplit(t," "), 2,-1)
allowed = "Ναβγδεϵζηθικλμνξοπρστυφϕχψωϐϑϰϱςϖ";
strspn(t, allowed)
--> t = matrix(strsplit(t," "), 2,-1)
 t  =
  "Να"           "τα"     "ή"   "μην"          "τίποτα:"  "ίσοι"    "αποφυγής"
  "αμφιβάλλετε"  "πάντα"  "να"  "αμφιβάλλετε"  "δύο"      "τρόποι"  "σκέψης."

--> allowed = "Ναβγδεϵζηθικλμνξοπρστυφϕχψωϐϑϰϱςϖ";
--> strspn(t, allowed)
 ans  =
   2.   2.   0.   3.   1.   0.   6.
   5.   1.   2.   5.   1.   2.   2.

Ver Também

  • strcspn — comprimentos do início dos textos até que um caractere entre aqueles proibidos
  • strncpy — Obtém e fornece os N primeiros caracteres dos textos fornecidos
  • part — extração de strings
Report an issue
<< strsplit Cadeias de Caracteres (Strings) strstr >>

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:
Mon Jan 03 14:35:27 CET 2022