Reputation: 2626
I am looking for my changes in log file. Here is example:
"2-11-2016 11:39:27 CET","[email protected]","Changed Class1 Apex Class code","Apex Class",""
"2-11-2016 12:39:27 CET","[email protected]","Changed Class2 Apex Class code","Apex Class",""
"2-11-2016 13:39:27 CET","[email protected]","Changed Class2 Apex Class code","Apex Class",""
"2-11-2016 14:39:27 CET","[email protected]","Changed Class1 Apex Class code","Apex Class",""
"2-11-2016 15:39:27 CET","[email protected]","Changed Class3 Apex Class code","Apex Class",""
...
"2-11-2016 15:39:27 CET","[email protected]","Changed FirstClass Apex Class code","Apex Class",""
"2-11-2016 15:39:27 CET","[email protected]","Changed SecondClass Apex Class code","Apex Class",""
I already know that I changed Class1 and Class2. So I need to find another classes that I changed (SecondClass in this example)
how to create regex to exclude Class1 and Class2? I use search in Sublime Text
Upvotes: 1
Views: 203
Reputation: 627082
It appears you need to match some string that is not followed with a number (that you are going to add manually after each match) as a whole word.
You may use a negative lookahead based regex with a group of alternatives (...|...|etc.)
and a word boundary \b
:
"[email protected]","Changed Class(?!(123|12|1|2|3)\b)
|
---------- a known part --------------------|negative lookahead|
The negative lookahead fails the match if the known part is followed with 123
, or 12
, etc. followed with a word boundary (see (123|12|1|2|3)\b
). The capturing group can be replaced with a non-capturing one that is only used for grouping: (123|12|1|2|3)
=> (?:123|12|1|2|3)
(meaning it won't put any subtext into $1
, Group 1).
Upvotes: 2