I have to parse a text where with is a key word if it is not surrounded by square brackets. I have to match the keyword with. Also, there must be word boundaries on both side of with.

Here are some examples where with is NOT a keyword:

  • [with]
  • [ with ]
  • [sometext with sometext]
  • [sometext with]
  • [with sometext]

Here are some examples where with IS keyword

  • with
  • ] with
  • hello with
  • hello with world
  • hello [ world] with hello
  • hello [ world] with hello [world]

Anyone to help? Thanks in advance.

Edit
Report