Scilab String
Scilab String
Eg:
A=
['welcome','to' ,'strings']
convstr(A,'u')
output: !WELCOME TO STRINGS !
2. grep() : Find matches of a string in a vector of strings
Eg: 1. txt=['find matches of a string in a vector of strings'
'search position of a character string in an other string'
'Compare Strings'];
grep(txt,'strings')
ans :
1.
grep(txt,['strings' 'Strings'])
ans: 1.
1.
2. str = ["hat";"cat";"hhat";"chat";"hcat";"ccchat";"at";"dog"]
str =
!hat
!
!
!
!cat
!
!
!
!hhat !
!
!
!chat !
!
!
!hcat !
!
!
!ccchat !
!
!
!at
!
!
!
!dog
!
1.
2.
3.
4.
5.
6.
= 2.
5.
8.
3. isalphanum ()
It checks if characters of a string are alphanumerics.
s = '%%%%WelcometoStrings!!!!';
isalphanum(s)
ans = F F F F T T T T T T T T T T T T T T T T F F F F
4. isascii(str) -Return Boolean if the given string is in 7 bit US-ASCII character code
letters = [115.
99.
105.
108.
105.
108.
97.
97.
98.]
letters =
115.
99.
98.
isascii(letters)
ans = T T T T T T
ascii(letters) --- returns the character for the respective codes.
ans = scilab
5. isdigit(Str) check that characters of a string are digits between 0 and 9 and returns a
Boolean matrix
6. isletter(str) --- check that characters of a string are alphabetic letters and returns a
Boolean matrix
7. isnum(str)
Eg: s = ['123','A','$'];
isnum(s)
ans = T F F
8. Length(str) Returns the length of the string
Eg: s = ['123','A','$'];
length(s)
ans =
3.
1.
letters = [115.
1.
99.
105.
108.
97.
98.]
length(letters)
ans =
6.
strstr(s,'fine')
ans =
13.
Strindex(str,element) Return the index position of the element
present in the given entire string.
strindex(s,'e')
ans =
2.
7.
9.
22.
24.
29.
34.
38.
43.
45.
14. Strcmp(str1,str2) - Compares two strings str1 and str2. If both strings are same
0 is returned. If they are reverse, 1 is returned. If there is a mismatch, then -1 is
returned. Case dependent.
strcmp('Scilab','scilab')
ans = - 1.
strcmp('scilab','scilab')
ans =
0.
strcmp('scilab','balics')
ans =
1.
0.