Home > Community > Forums > Custom IC SKILL > How to parse a string in skill?

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 How to parse a string in skill? 

Last post Tue, Mar 19 2013 12:13 AM by Andrew Beckett. 7 replies.
Started by Sandeep4386 11 Mar 2013 10:30 AM. Topic has 7 replies and 1327 views
Page 1 of 1 (8 items)
Sort Posts:
  • Mon, Mar 11 2013 10:30 AM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    How to parse a string in skill? Reply

    Hi,

    I want to parse a string and rename it.

    e.g. I would like to check for a cell name, and if there is an hyphen(-) in a cell name, I would like to convert it to an underscore(_).

    so if a cell name is 'create-gds'  I want to convert it to 'create_gds'. Any help would be appreciated. 

     

    -Sandeep 

    • Post Points: 35
  • Mon, Mar 11 2013 3:57 PM

    • dmay
    • Top 25 Contributor
    • Joined on Thu, Jul 17 2008
    • Allen, TX
    • Posts 386
    • Points 7,290
    Re: How to parse a string in skill? Reply

    Here is one way:

    s="create-gds"
    when(rexMatchp("-" s)
        rexCompile("-")
        s=rexReplace(s "_" 0)
    )

    Derek

    • Post Points: 20
  • Mon, Mar 11 2013 3:58 PM

    Re: How to parse a string in skill? Reply

    Sandeep,

    In IC61, you can do:

    ; only need to compile the pattern once
    hyphen=pcreCompile("-")
    ; then any time you need to do the replace, can reference the pattern object in var hyphen
    cellName="create-gds"
    newCell=pcreReplace(hyphen cellName "_" 0)

    In IC61 and IC5141 you can use the less powerful rex functions (but the compiled pattern will get overwritten if it is used elsewhere since it only has a single compiled pattern at once):

    rexCompile("-")
    cellName="create-gds"
    newCell=rexReplace(cellName "_" 0)

    The pcre functions have a much richer pattern matching syntax - see the PCRE web site for more details.

    Regards,

    Andrew.

    • Post Points: 20
  • Tue, Mar 12 2013 12:46 AM

    • marcelpreda
    • Top 150 Contributor
    • Joined on Tue, Jan 19 2010
    • Bucharest, Romania
    • Posts 43
    • Points 695
    Re: How to parse a string in skill? Reply

     Hi *,

    My feeling is that for char substitution the most safe,simple, fast way is to use buildString() and parseString() procedures.

    myCellName = "create-gds-2"
    myCellName = buildString(parseString(myCellName "-") "_")
    "create_gds_2"

     

    BR,

    Marcel

     

     

    • Post Points: 20
  • Tue, Mar 12 2013 1:21 AM

    Re: How to parse a string in skill? Reply

    Marcel,

    Actually I'd go for a regular expression approach. If you have multiple occurrences of the delimiter, or leading or trailing delimiters, it won't work properly. For example:

    myCellName="-hello-world--test"
    myCellName = buildString(parseString(myCellName "-") "_")
    "hello_world_test"

    Kind Regards,

    Andrew.

    • Post Points: 20
  • Tue, Mar 12 2013 10:33 AM

    • Sandeep4386
    • Top 500 Contributor
    • Joined on Fri, Jul 20 2012
    • Tempe, AZ
    • Posts 25
    • Points 395
    Re: How to parse a string in skill? Reply
    Thank you everyone. rexReplace worked perfectly.
    • Post Points: 5
  • Mon, Mar 18 2013 2:50 PM

    • RFStuff
    • Top 25 Contributor
    • Joined on Tue, Feb 5 2013
    • Posts 214
    • Points 3,780
    Re: How to parse a string in skill? Reply

     Dear Andrew,

    This type of replacement happens where ? Is it in the Schematic viewer or in the Created Netlist or in the Layout Editor ?

    Kind Regards,

    • Post Points: 20
  • Tue, Mar 19 2013 12:13 AM

    Re: How to parse a string in skill? Reply

    I don't understand your question. This post is about doing pattern replacement in SKILL, so it's nothing to do with a particular application. 

    Regards,

    Andrew 

    • Post Points: 5
Page 1 of 1 (8 items)
Sort Posts:
Started by Sandeep4386 at 11 Mar 2013 10:30 AM. Topic has 7 replies.