i have string pattern i'm trying match. can contain words enclosed within 2 curly braces. these curly braces have well-formed , cannot nested.
for example:
i have {{example}} right here {{is}} {{example}} right {{ {{ example }} wrong }} {{ }}example {{ { wrong }}
i have constructed regex seems work long , think can simplified.
"^([^{}]*\\{\\{([^{}]*)\\}\\}[^{}]*)+$"
is there way can simplify this?
it easier negative match. is, not allowed:
\\{\\{[^}]*\\{
and use matcher.find(). trying positive match difficult same reason using regex against xml problematic.
if want grab contents of braces should suffice
\\{\\{(\\w+\\)}\\}
Comments
Post a Comment