Reputation: 600
Using C# Regex
Simple Input: [testA].[max] [testB]
Match: [testB]
Input: 5/[test1] [test2].[max] [test3]*2 [min]
Match:[test1] [test3] [min]
I want to match anything with like [Whatever] but not match [Whatever].[(min|max|mean|sum|median)]
This works sort of it does not match [min] on its own.
(?!\[((\w|[.])+)\]\.\[(min|max|mean|sum|median)\])\[((?!min|max|mean|sum|median).+?)\]
Upvotes: 0
Views: 667
Reputation: 952
How about
(?<!\.)\[[A-Za-z0-9]*\](?!\.\[.*\])
(?<!\.)
- Negative lookbehind to prevent .[max]
matching matching as well.\[[A-Za-z0-9]*\]
- Match [...]
, add other characters if necessary.(?!\.\[.*\])
- Negative lookahead to ignore [...].[...]
.Upvotes: 1