• 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. how to parse string and number

Stats

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

how to parse string and number

saurabh96
saurabh96 over 4 years ago

Hello guys,

i have list of rules  i.e  rules_Entry=  ("chk_abc_1 (diodes)" "chk_xyz_2 (bjt)" "chk_jhg_3 (res)" "chk_lmn_4 (cap)" "chk_uvw_5 (inductor)" )

check = buildString(
foreach(mapcar entry form->rules_Entry->value
car(parseString(entry))
)
","
)

it will give output as chk_abc_1,chk_xyz_2,chk_jhg_3,lmn_4,chk_uvw_5

Now i want that it should print only numbers i.e 1,2,3,4

rules_print= rexCompile("_")
newCell=rexReplace(check " " 0)

rules_number = buildString(
foreach(mapcar entry form->newCell->value
nth(2 parseString(entry))
)
","
)

but am getting error...how can i acheive output as rules_number= 1,2,3,4,5

 

Thanks in advance

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 4 years ago

    The code above is a bit confused - it seems to be looking for a field on the form called newCell, yet newCell is a variable. I have a sneaking suspicion you're throwing lines of code together without really understanding what are variables, what are fields on the form, and so on? Also, if you are getting errors, it's far better to actually show the error you're getting, and ideally enough code (as I have said several times before) to be able to show the problem. At the moment you only have pieces of the puzzle shared.

    Anyway, assuming that you're starting from your rules_Entry field, you could do this:

    numPat=pcreCompile("\\d")
    rules_number=buildString(
      foreach(mapcar entry form->rules_Entry->value
        pcreExecute(numPat entry)
        pcreSubstitute(numPat "\\0")
      )
      ","
    )

    In your code, it's a bit pointless using the rex functions to change the underscore to a space, and then use parseString with space. You might just as well have used parseString with "_ " as a delimiter (so space or underscore). So you could have done:

    rules_number=buildString(
      foreach(mapcar entry form->rules_Entry->value
      nth(2 parseString(entry "_ "))
      )
      ","
    )

    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