Scilab is capable of processing strings such as
combination, conversion, and separation. These functions listed in Table 1 that are useful in programming. The functions including ascii, strtod, and strcmp, were introduced in the previous section. This asection addresses on the rest functions.
² +:
combine strings
The operator + combines two or more strings.
² strsplit:
split a string into a column vector of strings
The function strsplit splits a string into a column vector of strings with or without a specified separator. The following illustrates the split of a string with different specified separator.
Case 1 shows that the string A is split into individual characters when no separator is specified. In case 2, the string A is split into 3 substrings, ‘Welcome’, ‘to’, and ‘Taiwan’. Compared with the case 2, case 3 shows that the string A was not split because the specified separator was not found in the string. The case 4 and case 5 shows the splits with the separators defined by the characters ‘W’ and ‘w’, respectively.
Here is a question. Based on the result of case 2 in example 1, can we use strsplit to split a string into individual words with a space separator, and remove all white spaces at the same time? Check the below example.
² tokens: returns the tokens of a
character sting

沒有留言:
張貼留言