我有这样的文本要扫描:
-- 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
我只想匹配 ( MaxWidth=6
) 的块。
我正在做一些测试,但出了点问题......例如使用这个 RegEx 表达式:
(Begin[\s\S]+?(MaxWidth.*=)[\s\S]+?End)
我正确匹配了上面代码中可见的树块。
然后,如果我尝试修改正则表达式以仅匹配“MaxWidth”属性的值为“6”的块:
(Begin[\s\S]+?(MaxWidth.*= 6)[\s\S]+?End)
我只正确匹配了两个块,但第一个块是错误的。第一场比赛:
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
它从第一个“开始”开始,并以第二个块中的正确属性值结束。那是错误的。
我希望 ( MaxWidth=6
) 在每个 Begin...End 块内匹配。像这样的东西(参考我上面的代码):
拳赛:
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
第二场比赛:
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
我怎样才能做到这一点?我的正则表达式有什么问题?
谢谢你。