I have a text to scan like this:
-- FIRST BLOCK
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG44_CLIFOR"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 8
End
-- SECOND BLOCK
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG44_CLIFOR"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 6
End
-- THIRD BLOCK
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG16_ANAG"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 6
End
I want to match only blocks where (MaxWidth=6
).
I'm doing some tests but something is wrong... for example using this RegEx expression:
(Begin[\s\S]+?(MaxWidth.*=)[\s\S]+?End)
I correctly match the tree blocks visible in my code above.
Then if I try to modify the regEx for matching only the blocks with the value '6' for 'MaxWidth' property:
(Begin[\s\S]+?(MaxWidth.*= 6)[\s\S]+?End)
I correctly match only two blocks but the first one is wrong. First match:
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG44_CLIFOR"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 8
End
-- SECOND BLOCK
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG44_CLIFOR"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 6
End
It starts with the first 'Begin' and terminate with the correct property value in the second block. That's wrong.
I want that the (MaxWidth=6
) is matched inside each Begin...End block. Something like this (referring to my code above):
Fist match:
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG44_CLIFOR"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 6
End
Second match:
Begin PRJFW_EDITM.TXT_EDITM TXT_CLIFOR
Height = 300
Left = 2685
DBField = "CG16_ANAG"
Caption = "Codice cliente fornitore"
Object.Tag = "Codice cliente fornitore"
MaxWidth = 6
End
How can I do that? What's wrong in my regEx?
Thank you.