• 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. Regular expression replace with backslash

Stats

  • Locked Locked
  • Replies 2
  • Subscribers 143
  • Views 17285
  • 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

Regular expression replace with backslash

greatqs
greatqs over 8 years ago

Objective is to change string like below

"XYZ:DGND" into "\XYZ\:DGND"

where XYZ represents a multibit digits (e.g. XYZ = 642) and DGND can be some other net name

I tried below and it doesn't work. Anyone can help?

pcreReplace(pcreCompile("([0-9]*)") "642:DVDD" "\\\\1" 1)
"\\1:DVDD"
pcreReplace(pcreCompile("([0-9]*)") "642:DVDD" "\\\\1\\" 1)
"\\1"

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 8 years ago

    You've not got enough backslashes (believe it or not)! You'd need this:

    pat=pcreCompile("(\\d+)")
    thing="642:DVDD"
    pcreReplace(pat thing "\\\\\\1\\\\" 1)

    The first pattern is equivalent to yours. The reason why you need so many backslashes is because backslash has meaning in SKILL strings and in regular expressions. To get a regular expression escape, you need to have two backslashes. If you really want a backslash in the regular expression, you'll need four. The pattern recall would therefore be \\1 (you really want "\1" in the string, so you have to escape it for SKILL), and then four backslashes either side of that.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • greatqs
    greatqs over 8 years ago
    Andrew,

    Thanks for the explanation.
    • 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