• 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. Pattern Matching of Regular Expressions

Stats

  • Locked Locked
  • Replies 5
  • Subscribers 142
  • Views 19523
  • 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

Pattern Matching of Regular Expressions

archive
archive over 17 years ago

I’m studing this topic and I met problem to understand this example…
 
rexCompile("\\([a-z]+\\)\\.\\1")        => t
rexExecute("abc.bc")                    => t
rexExecute("abc.ab")                    => nil
 
It is not clear why the second case is nil and if I type:
 
rexCompile("\\([a-z]+\\)\\.\\1")        => t
rexExecute("abc.bc")                    => t
 
rexSubstitute( “debug: \\0" ) => debug: bc.bc
 
Why the result is bc.bc?
 
 \1 register should not point to abc?
 
Please, could you clarify me how it works? Where could I find accurate information as the cdsdoc is not clear on how registers work.
 
Giuseppe

 


Originally posted in cdnusers.org by Giuseppe Greco
  • Cancel
Parents
  • archive
    archive over 17 years ago

    In the first case, you're expecting that the \([a-z]+\) matching happens in isolation. It doesn't. What happens is that it tries to match the entire pattern, and so it will be looking for a combination of 1 or more a-z characters. followed by ".", followed by exactly the same combination. Since it can successfully do that if the \1 part ends up as "bc", then it will do that.

    If you'd have anchored the pattern:

    rexCompile("^\\([a-z]+\\)\\.\\1")

    then this would have forced it to match the complete sequence of characters before the ".", in which case only "abc.abc" would have matched.

    So as was stated previously, you're matching:

    blablahblaXXXX.XXXX

    where XXXX is a variable length sequence of a-z - but is the [u]same[/u] either side of the dot.

    Regards,

    Andrew.


    Originally posted in cdnusers.org by adbeckett
    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
Reply
  • archive
    archive over 17 years ago

    In the first case, you're expecting that the \([a-z]+\) matching happens in isolation. It doesn't. What happens is that it tries to match the entire pattern, and so it will be looking for a combination of 1 or more a-z characters. followed by ".", followed by exactly the same combination. Since it can successfully do that if the \1 part ends up as "bc", then it will do that.

    If you'd have anchored the pattern:

    rexCompile("^\\([a-z]+\\)\\.\\1")

    then this would have forced it to match the complete sequence of characters before the ".", in which case only "abc.abc" would have matched.

    So as was stated previously, you're matching:

    blablahblaXXXX.XXXX

    where XXXX is a variable length sequence of a-z - but is the [u]same[/u] either side of the dot.

    Regards,

    Andrew.


    Originally posted in cdnusers.org by adbeckett
    • 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