• 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. SKILL regex pattern matching

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 144
  • Views 2981
  • 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

SKILL regex pattern matching

anushar
anushar 10 months ago

Hi,

I have a string "[@global_vddi:%:vddi!]" which I need to process to remove "@[]" chars. The desired result is "global_vddi:%:vddi!". I tried the following in CIW

netExpr = "[@global_vddi:%:vddi!]"
rexCompile("\\([a-zA-Z0-9_:!%]+\\)")
t
rexExecute(netExpr)
t
rexSubstitute( "\\0" )
"global_vddi:%:vddi!"

and I achieved the desired value. I added the same code to my script but it didn't work. In my script rexExecute returns 't' but rexSubstitute returns 'nil' 

Here is the snippet from my script

netExpr = dbGetTermNetExpr(term)
if(netExpr then
rexCompile("\\([a-zA-Z0-9_:!%]+\\)")
rexExecute(netExpr)
netExpr1 = rexSubstitute( "\\0" )

...

. ..)  and trace log showing the variable values as the code executes

stopped before evaluating dbGetTermNetExpr(term)
after evaluating dbGetTermNetExpr(term)==> "[@global_vddi:%:vddi!]"
after evaluating (netExpr = dbGetTermNetExpr(term))==> "[@global_vddi:%:vddi!]"
stopped before evaluating if(netExpr then rexCompile("\\([a-zA-Z0-9_:!%]+\\)") rexExecute(netExpr) (netExpr1 = rexSubstitute("\\0")) ... )
stopped before evaluating rexCompile("\\([a-zA-Z0-9_:!%]+\\)")
after evaluating rexCompile("\\([a-zA-Z0-9_:!%]+\\)")==> t
stopped before evaluating rexExecute(netExpr)
after evaluating rexExecute(netExpr)==> t
stopped before evaluating (netExpr1 = rexSubstitute("\\0"))
stopped before evaluating rexSubstitute("\\0")
after evaluating rexSubstitute("\\0")==> nil
|[2]netExpr1 set to nil, was nil

Any help or suggestions as to why the code executes differently in CIW and when called from a SKILL script file will be much appreciated.

I also tried a different approach using rexReplace instead of rexSubstitute but couldn't get the regex pattern correct. The code I tried in CIW using rexReplace is as follows

a = "[@global_vddi:%:vddi!]"
"[@global_vddi:%:vddi!]"
rexCompile("\\([@\\[\\]]*\\)")
t
rexReplace(a "" 0)
"global_vddi:%:vddi!]"

Only '@[' get replaced and ']' is still present. The regex pattern contains '\\]' to match the closing square bracket yet it is not replaced. Please let me know what I'm missing in these 2 scenarios.

Any help is much appreciated!!

Regards,

Confused SKILL user 

  • Cancel
Parents
  • henker
    henker 9 months ago

    I wouldn't bother with a regex here if not really necessary (woukd be "^\\[@([^]]+)\\]$"),
    e.g. dbParseSigNetExpr is prob. easier to use, and there are also other options, but cannot post them; the forum gives me error, when I add them.

    Regards,

    str = "[@ABC:%:abc!]"
    ; regex
    reg = pcreCompile("^\\[@([^]]+)\\]$")

    ; advantage of regex is that it can test the format
    when(pcreExecute(reg str)
    ; the first capture is in \\1
    printf("regex : %s\n" pcreSubstitute(reg "\\1"))
    )


    ; also tests the format
    arr = dbParseSigNetExpr( str ) ; splits into '(@ ABC % abc!)

    ; compine to your liking
    printf("sigparse+print: %s:%%:%s\n" cadr(arr) cadddr(arr))
    printf("sigparse+build: %s\n" buildString(cdr(arr) ":"))

    ; split on unwanted chars
    printf("strparse : %s\n" car(parseString( str "[@]")))

    ; or just remove the envelop with substring

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • henker
    henker 9 months ago

    I wouldn't bother with a regex here if not really necessary (woukd be "^\\[@([^]]+)\\]$"),
    e.g. dbParseSigNetExpr is prob. easier to use, and there are also other options, but cannot post them; the forum gives me error, when I add them.

    Regards,

    str = "[@ABC:%:abc!]"
    ; regex
    reg = pcreCompile("^\\[@([^]]+)\\]$")

    ; advantage of regex is that it can test the format
    when(pcreExecute(reg str)
    ; the first capture is in \\1
    printf("regex : %s\n" pcreSubstitute(reg "\\1"))
    )


    ; also tests the format
    arr = dbParseSigNetExpr( str ) ; splits into '(@ ABC % abc!)

    ; compine to your liking
    printf("sigparse+print: %s:%%:%s\n" cadr(arr) cadddr(arr))
    printf("sigparse+build: %s\n" buildString(cdr(arr) ":"))

    ; split on unwanted chars
    printf("strparse : %s\n" car(parseString( str "[@]")))

    ; or just remove the envelop with substring

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
No Data

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