Scilab Website | Contribute with GitLab | Mailing list archives | ATOMS toolboxes
Scilab Online Help
6.0.1 - English

Change language to:
Français - 日本語 - Português - Русский

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

Scilab Help >> Strings > strspn


get span of character set in string


res = strspn(str1, str2)



a character string or matrix of character strings.


a character string or matrix of character strings.


a matrix of character strings.


res = strspn(str1, str2) returns the length of the initial portion of str1 which consists only of characters that are part of str2.

str1 must have same dimensions as str2 or str2 must be 1x1 string. The output will be the same dimensions as str1 in both cases.


i = strspn("129th","1234567890");
mprintf ("The length of initial number is %d.\n",i);
i = strspn(["129th","130th"],["1234567890","130t"])

See also

  • strcspn — get span until character in string
Report an issue
<< strsplit 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 Feb 12 19:26:51 CET 2018