• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X Scripting - Skill
  3. Parse a String with SKILL

Stats

  • Replies 3
  • Subscribers 19
  • Views 10894
  • Members are here 0
More Content

Parse a String with SKILL

leto
leto over 4 years ago

Hello All,

I have a string  C200_2

I would like break it up to separate alphabets, numbers & special characters

The results should be a list ("C" "200" "_" "2")

Is there a build in function of SKILL to do this?

If not, how should I do this manually?

Thanks All

  • Cancel
  • Sign in to reply
  • Kirti Sikri
    Kirti Sikri over 4 years ago

    Hello,

    You can use parseString as shown in the code below

    parseString("C200_2" "")

    About parseString

    parseString breaks a string into a list of substrings with specified break characters, which are indicated by an optional second argument.

    Space is the default break character

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

    From COS

    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, insert (“ “) into the result list at each occurrence of S_breakCharacters. It generates the list of strings so that if the S_breakCharacters has a single character then the generated string is:

    buildString( parseString( string delimiter t) delimiter)

    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.

    Value Returned

    l_strings

    List of strings parsed from S_string.

    Example

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

    Space is the default break character

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

    e is the break character.

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

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

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

    Both . and / are break characters.

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

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

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

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

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

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

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • B Bruekers
    B Bruekers over 4 years ago

    If you know the format of your input string then you can make a regular expression to 'extract' the values.

    pcre = pcreCompile("(\\w)(\\d+)_(\\d+)")
    pcreExecute(pcre "C200_2")
    pcreSubstitute("\\1")
    pcreSubstitute("\\2")
    pcreSubstitute("\\3")

    Alternatively, there is an undocumented function which seems to do something that you need:

    _alphaNumBreakIntoChunks("C200_2")
    ("C" "200" "_" "2")

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • leto
    leto over 4 years ago in reply to B Bruekers

    Thanks Bruekers!!

    That is exactly what I needed :D

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information