• 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

Stats

  • Locked Locked
  • Replies 4
  • Subscribers 143
  • Views 15570
  • 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

Sridhar123
Sridhar123 over 12 years ago

 Hello all,

I have a small query on pattern matching . Actually I am trying to search for the data in between two keywords say "REVA" and "REVB" from the userdefined input data (assumed that the keywords "REVA" , "REVB ... are always present in the input data without duplicates or repetitions) . Is there a way that I search the user defined input data  for two keywords "REVA" and "REVB" and what ever the data inbetween this two words has to be dumped in to a variable REVA , similarly whatever the data that is present in between "REVB" and "REVC" to REVB field  etc , ineffective I am seperating the respective revision data to their corresponding fields from the given input data.

May be the following ex gives more info:

;Skill starts here 

 procedure(testpattern()
inputdata = "REVA: This Text belongs to revision A \n REVB: This Text belongs \n to revision B. REVC: This \n Text belongs to revision C"
input = hiCreateMLTextField(?name 'input ?prompt "INPUT" ?value inputdata  ?hasVerticalScrollbar nil ?hasHorizontalScrollbar nil)
REVA = hiCreateMLTextField(?name 'REVA ?prompt "REVA" ?value ""  ?hasVerticalScrollbar nil ?hasHorizontalScrollbar nil)
REVB = hiCreateMLTextField(?name 'REVB ?prompt "REVB" ?value ""  ?hasVerticalScrollbar nil ?hasHorizontalScrollbar nil)
REVC = hiCreateMLTextField(?name 'REVC ?prompt "REVC" ?value ""  ?hasVerticalScrollbar nil ?hasHorizontalScrollbar nil)
fillform=hiCreateButton(?name 'fillform ?buttonText "Fill Form" ?callback "fillform()")
testform = hiCreateAppForm(
     ?name 'testform
     ?formTitle "Pattern Matching"
     ?fields list(
                    list(input  15:15  400:70 50)
                    list(REVA  15:100  400:20 50)
                    list(REVB  15:150  400:20 50)
                    list(REVC  15:200  400:20 50)
                    list(fillform  15:260  100:30 50))

?initialSize t
)
hiDisplayForm(testform)
)

 ; ends here 

 

Now what I require is the fillform() function must put the data say " This Text belongs to revision A" in to REVA field by searching the input data. Similarly for other fields "REVB" "REVC".

I have tried using rexMatchp() and other pattern matching functions but the return value is always a t or nil but not the data.

Is there a way to achieve this.

Thank you very much in advance for your time.

 

Best regards,

Sri. 

  • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

     Sri,

    How about this?

    procedure(fillform()
      let((reva)
        reva=pcreCompile("REVA:(.*)(REV[A-C]:|$)" pcreGenCompileOptBits(?dotAll t ?ungreedy t))
        revb=pcreCompile("REVB:(.*)(REV[A-C]:|$)" pcreGenCompileOptBits(?dotAll t ?ungreedy t))
        revc=pcreCompile("REVC:(.*)(REV[A-C]:|$)" pcreGenCompileOptBits(?dotAll t ?ungreedy t))
        pcreExecute(reva testform->input->value)
        testform->REVA->value=pcreSubstitute(reva "\\1")
        pcreExecute(revb testform->input->value)
        testform->REVB->value=pcreSubstitute(revb "\\1")
        pcreExecute(revc testform->input->value)
        testform->REVC->value=pcreSubstitute(revc "\\1")
      )
    )

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sridhar123
    Sridhar123 over 12 years ago

    Hello Andrew,

     

    Perfect , it worked as I wanted. Thank you very much Andrew onceagain.

    One more quick query  is it possible to make only the default value of the hiCreateMLTextField() as non editable while still providing an option for the user to enter his data . Because I want "REVA:" to be default value of the hiCreateMLTextField()  field and the user should not edit that (as while loading I am using "REVA:" as reference ) but he can enter his own data .( I don't know if it is possible).

     

    Best regards,

    Sri.

     

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 12 years ago

    Sri,

    I don't think I entirely understand what you mean - if you want to make only parts of the text editable, then that's not really possible. You probably could implement a ?modifyCallback to ensure that changes involving removal of the REVA part are not honoured, but that would be quite hard to implement if you selected a range of text bigger than the REVA part and then deleted REVA plus some other text - it wouldn't really be able to know what you did mean to remove and what you didn't - but maybe it could figure it out? (I didn't think about the algorithm).

    What I would probably do is not put the required text in the ML text box, but instead put it as a fixed label on the form. 

    Overall I can't really understand what your objective is, so it's hard to advise for certain.

    Regards,

    Andrew.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Sridhar123
    Sridhar123 over 12 years ago

     Hello Andrew,

     

    Yeah , you were correct I was just looking for  only parts of the text editable , so that the user wouldn't edit "REVA" . If REVA have been edited than I would  have problem while loading back the data.

    However I could solve this by ensuring that before printing the data to the file I am checking if there is "REVA:" or "REVB:" at the beginning of the correspoding field otherwise I am appending and then printing the data.So that I won't have any issue while loading the data back from the file.

     

    Andrew thank you very much for your support. 

     

    Best regards,

    Sridhar.

     

    • 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