I want to create a regular expression that captures text between @{ some text }
. I know how to do it for simple string, but in this case the text between the @{
}
might contain starting and ending curly braces which will be confused with the braces in @{
}
.
Example:
Input string:
This is some text that does not match the regex
@{
This is some text
{
This another text
{
inner text
}
}
}
@{
this is text2
}
another text that does not match the regex
@{
this is another text
{
another inner text
}
}
The result (3 matches) should be:
First match:
This is some text
{
This another text
{
inner text
}
}
Second match:
this is text2
Third match:
this is another text
{
another inner text
}
Can anybody tell me how to achieve this? I'm using PHP by the way.