• 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. Custom IC SKILL
  3. Is it possible to specify a variable with rexMatchp?

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 143
  • Views 16944
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is it possible to specify a variable with rexMatchp?

adeuser777
adeuser777 over 12 years ago

Hi,

Can we have a variable with rexMatchp?

My requirement is as below:

a = "m_1"

b = '("m_1" "m_1_1" "m_1_2")

c = setof(i  b  !rexMatchp("_[1-9]*$" i)   // This will return nil.

My desired output for c is "m_1" and at the same time, I want to exclude a_[1-9] where a="m_1"

Could you please guide? Is it possible with rexMatchp?

 

Thanks,

Ram 

 

  • Cancel
  • skillUser
    skillUser over 12 years ago

    Hi Ram,

    I'm confused as to what you want, your requirements are mutually exclusive - you want to match "m_1" but you don't want to match a (which is "m_1") - can you clarify your requirement please?

    Probably the trick will be to either build the rexMatchp test expression using sprintf() where the variable can be inserted into the test expression [e.g. sprintf(nil "%s*$" a) ], and/or make a more complex condition which can be written as a single compound/composite expression [e.g. "this" || ("that" && "theOther") - this OR (that AND theOther) ].

    Anyway, I hope this helps you.

    Regards,

    Lawrence.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    I assume you want:

    rexCompile(strcat(a "_[1-9]*$"))
    c=setof(i b !rexExecute(i))

    This will return ("m_1")

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • adeuser777
    adeuser777 over 12 years ago

    Sorry for not being clear. Let me explain what I am trying to do.

    "a" could fall under one of the following category.

    a = '(m1 m1_1 m1_2...)    or a = '(mn_1 mn_1_1 mn_1_2...)

    My end goal is to get the "original name (orig_name) with out _[1-9]. And if the original name itself had _[0-9] in it, I need to handle it appropriately.

     

    I have implemented the following to handle this scenario.

    rexCompile("_[0-9]$")

    if(rexExecute(orig_name) then mainInst = car(setof(i insts !rexMatchp("@" i) && !rexMatchp("_[0-9]_[1-9][0-9]*$" i)))

    else parentInst = car(setof(i insts !rexMatchp("@" i) && !rexMatchp("_[1-9][0-9]*$" i)))

     

    Is there a better way to handle this? Thanks. 

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Your requirements are still as clear as mud, I'm afraid. I've really no idea what you are trying to achieve. Originally a was a string - now it is a list. Your example doesn't even mention a so I don't know what you are trying to do.

    Best thing is to describe a number of different sets of input and output data - with some detailed description of what you want it to do.

    Are you using IC61? If so, the pcre functions allow a lot more power in the regular expressions than the old rex functions.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • adeuser777
    adeuser777 over 12 years ago
    Hi Andrew,
    My apologies. I have corrected the description.

    "b" could fall under one of the following category.

    Case 1:
    b = '("/i0/i1/m1" "i0/i1/m1_1" "i0/i1/m1_2"...)
    a = "m1"

    Expected output = "i0/i1/m1"

    Case 2:
    b = '("/i0/i1/mn_1" "/i0/i1/mn_1_1" "/i0/i1/mn_1_2"...)
    a = "mn_1"

    Expected output = "i0/i1/mn_1"

    My end goal is to get the original name "a" with out _[1-9]. And if the original name itself had _[0-9] in it, I need to make sure, it's handled appropriately.

    I have implemented the following to handle this scenario.

    rexCompile("_[0-9]$")

    if(rexExecute(a) then mainInst = car(setof(i b !rexMatchp("_[0-9]_[1-9][0-9]*$" i))

    else mainInst = car(setof(i b !rexMatchp("_[1-9][0-9]*$" i))

    The above lines are doing the job. Could you please let me know if there is a better way?

    Thanks.
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Isn't this just  rexMatchList(strcat(a "$") b) ? Or the car of that if you want the first match?

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

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