New to Regex. I want to validate to this format:
- Any character allowed, except '{' and '}'.
- A '{' char must be followed by one of specific strings
After these strings any character can go
- Each '{' must have a closing '}'
- Nesting of '{'s is allowed
Example:
abc{FILE:any text} def {FILE:mno{ENV:xyz}}
FILE:
and ENV:
are an example of specific strings required after a '{' char.
I wrote this regex:
^
(
[^\{\}]+
|
(?<Depth>\{)(FILE:|ENV:)
|
(<-Depth>\})
)*
(?(Depth)(?!))
$
but it doesn't match my desired format. What i miss?
Thanks a lot.
EDIT: Links that do the same, succesfully i hope:-) MSDN, Other site