moleschott
moleschott

Reputation: 161

Need help for this regex

(?<=[MVAZ])([^MVAZ]*)(?=[MVAZ]?)

Hi. I want to match everything from 'MVAZ' characters to any other 'MVAZ' characters not in curly braces. If I do not write any 'MVAZ' between curly brackets, pattern works but sometimes I need to use this characters in curly braces.

Demo

Upvotes: 1

Views: 36

Answers (1)

Avinash Raj
Avinash Raj

Reputation: 174706

You may try this,

(?<=[MVAZ])(?:\{[^{}]*\}|[^MVAZ])*(?=[MVAZ])

This would match the curly bracked block greedily if there is any.

DEMO

Upvotes: 2

Related Questions