• 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. Remove /* this is a comment line */ from a file

Stats

  • Locked Locked
  • Replies 6
  • Subscribers 144
  • Views 19418
  • 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

Remove /* this is a comment line */ from a file

Charley Chen
Charley Chen over 14 years ago

Dear All,

I wnat to remove a file which each line has  /*  a bc  d */  .

I use infile & outfile command.

How to do it ?

 

Thank you,

Charley

 

  • Cancel
Parents
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Hi Charley,

    It's an attempt to limit the fact that wildcards match as much as possible - so if you had /* something */ */ the pattern will match up to the first */ . If your pattern was "/\\**\\*/" then it would match up to the second */ (which is not the extent of the comment).

    Note I escaped the * which are part of the comment - can't see Lawrence's post right now, but in the pattern you reference below that hasn't been done, so it would also match "/////blah blah /" which isn't right. It also wouldn't match "/* test * comment */" or "/* test./ comment */" because the [^*/] bit will prevent it matching either of the / or * characters within the comment. It also won't match multi-line comments.

    This could almost certainly be handled with the more advanced pattern matching available in the pcre functions, but if you're merely looking for the presence of a comment, it is probably sufficient to just search for "/\\*" - i.e. the start of the comment.

    Regards,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • Andrew Beckett
    Andrew Beckett over 14 years ago
    Hi Charley,

    It's an attempt to limit the fact that wildcards match as much as possible - so if you had /* something */ */ the pattern will match up to the first */ . If your pattern was "/\\**\\*/" then it would match up to the second */ (which is not the extent of the comment).

    Note I escaped the * which are part of the comment - can't see Lawrence's post right now, but in the pattern you reference below that hasn't been done, so it would also match "/////blah blah /" which isn't right. It also wouldn't match "/* test * comment */" or "/* test./ comment */" because the [^*/] bit will prevent it matching either of the / or * characters within the comment. It also won't match multi-line comments.

    This could almost certainly be handled with the more advanced pattern matching available in the pcre functions, but if you're merely looking for the presence of a comment, it is probably sufficient to just search for "/\\*" - i.e. the start of the comment.

    Regards,

    Andrew
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Children
  • mbracht
    mbracht over 7 years ago in reply to Andrew Beckett

    Andrew, pcreCompile() takes an optional second argument to define all kinds of options - those options in turn need to be generated with pcreGenCompileOptBits(..)
    So to turn on non-greedy matching you need to go like that:

    (pcreCompile <whatever pattern> (pcreGenCompileOptBits ?ungreedy t))

    Max

    • 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