• 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. Accessing regex capture group content

Stats

  • Locked Locked
  • Replies 1
  • Subscribers 143
  • Views 5654
  • 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

Accessing regex capture group content

Zol
Zol over 1 year ago

Is there a way to return the content of the capture groups in a regex match? Below is an example, where I would like to capture the two numbers in the net name:

re = pcreCompile(".*<([0-9]+):([0-9]+)>")
a = pcreExecute(re "node<31:16>")

pcreExecute only returns a True/False result, while I would like to access the content of the capture groups. In this case it would be: list("31" "16")

The solution below works, but it looks ugly...

rel = pcreCompile("^.*<([0-9]+):.*$")
left_number=pcreReplace(rel "node<31:16>" "\\1" 1)
rer = pcreCompile("^.*:([0-9]+)>.*$")
right_number=pcreReplace(rer "node<31:16>" "\\1" 1)
  • Cancel
  • Andrew Beckett
    Andrew Beckett over 1 year ago

    You can do it with pcreSubstitute which is a bit more direct than pcreReplace. I also wrote a utility function around it here: https://community.cadence.com/cadence_technology_forums/f/custom-ic-skill/47374/get-a-list-of-the-matched-backreferences

    Andrew

    • Cancel
    • Vote Up +1 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