Reputation: 113
I have bunch of strings like:
object field: TMemo
Left = 6
Top = 23
Width = 390
Height = 156
Anchors = [akLeft, akTop, akRight, akBottom]
ScrollBars = ssVertical
TabOrder = 1
OnChange = fieldChange
OnKeyUp = fieldKeyUp
AddMenu = True
RightClickMoveCaret = True
RightEdge = 0
end
Or
object btn: TButton
Left = 5
Top = 3
Width = 89
Height = 21
Caption = 'Button'
TabOrder = 0
TabStop = False
OnClick = btnClick
end
I want to select all text except name of object (in this case field and btn) and every line that starts with [space][space]On.
I can select everything without name of field using regexp like this:
(object)|(: .*)|(end)|( .*)
But I'm not able deselect lines starting with "On". Can you help me join my regexp with this regexp excluding this lines I want from selection?:
(^(?:(?! On).)*$)
Upvotes: 0
Views: 33
Reputation: 163642
You could use a negative lookahead (?! On)( .*)
for the last alternation to check what is on the right is not 2 spaces followed by On:
(object)|(: .*)|(end)|(?! On)( .*)
Since your matches are at the start and the end of the stirng, a more precise match might be using anchors ^
and $
:
^(object)|(: .*)$|^(end)$|^(?! On)( .*)
Note that you can also get the matches without using capturing groups:
^object|: .*$|^end$|^(?! On) .*
Upvotes: 1