Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

parseString

parseString( 
S_string 
[ S_breakCharacters ] 
[ g_insertEmptyString ] 
) 
=> l_strings

Description

Breaks a string into a list of substrings with break characters.

Returns the contents of S_string broken up into a list of words. If the optional second argument, S_breakCharacters, is not specified, the white space characters, \t\f\r\n\v, are used as the default. If the third optional argument g_insertEmptyString is provided, an empty string is inserted under the following three conditions:

A sequence of break characters in S_string is treated as a single break character. By this rule, two spaces or even a tab followed by a space is the same as a single space. If this rule were not imposed, successive break characters would cause null strings to be inserted into the output list.

If S_breakCharacters is a null string, S_string is broken up into characters. You can think of this as inserting a null break character after each character in S_string.

No special significance is given to punctuation characters, so the “words” returned by parseString might not be grammatically correct.

Arguments

S_string

String to be parsed.

S_breakCharacters

List of individual break characters.

g_insertEmptyString

Generates the list of strings to include empty string when set to t. The default value is nil.

Value Returned

l_strings

List of strings parsed from S_string.

Examples

Space is the default break character.

parseString( "Now is the time" )   
=> ("Now" "is" "the" "time")

e is the break character.

parseString( "prepend" "e" )       
=> ("pr" "p" "nd" )

A sequence of break characters in S_string is treated as a single break character.

parseString( "feed" "e")           
=> ("f" "d")

Both . and / are break characters.

parseString( "~/exp/test.il" "./") 
=> ("~" "exp" "test" "il")

The single space between c and d contributes " " in the return result.

parseString( "abc de" "")          
=> ("a" "b" "c" " " "d" "e")

Splits the string at each occurrence of the delimiter character "-".

parseString( "-abc-def--ghi-" "-" )
=> ("abc"  "def"  "ghi")

Inserts an empty string at each occurrence of the delimiter character "-".

parseString( "-abc-def--ghi-" "-" t )
=> (""  "abc"  "def"  ""  "ghi"  "")
parseString "-abc" 
=> ("" "abc")
parseString "abc-" 
=> ("abc" "")
parseString "abc--xyz" 
=> ("abc" "" "xyz")

The above result can be used with buildString() to reconstruct the original string or replacing the delimiter character.

buildString( parseString( string delimiter t) delimiter)

Related Topics

String Functions

buildString

linereadstring

strcat

strlen

stringp


Return to top
 ⠀
X