REGEX Match [WildCard] but not [WildCard].[WildCard]

Mikes3ds

Using C# Regex

Example

Simple Input: [testA].[max] [testB]

Match: [testB]

Input: 5/[test1] [test2].[max] [test3]*2 [min]

Match:[test1] [test3] [min]

Definition

I want to match anything with like [Whatever] but not match [Whatever].[(min|max|mean|sum|median)]

Attempt

This works sort of it does not match [min] on its own.

(?!\[((\w|[.])+)\]\.\[(min|max|mean|sum|median)\])\[((?!min|max|mean|sum|median).+?)\]
Jonathan Twite

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 [...].[...].

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related