tags:

views:

45

answers:

1

I have this text:

Lorem ipsum dolor sit
{something.something({print.print(param1,param2)},param2)},
consectetur adipiscing elit.

Where i need a pattern that can replace everything but: something.something

The text something.something can contain [a-zA-Z.]

(I am using preg_replace)

Here is a site where you can test the code: http://www.spaweditor.com/scripts/regex/index.php

+1  A: 

Once you start talking about matching nested patterns (eg: matching the inner bracketed group in something like (foo (bar) fu)), then regex is the wrong tool. Regular Expressions are stateless, which, in this case, means that they can't count how many brackets are open.

If you are looking to do something like that, you might need to look into a parser

nickf
Although it's correct for pure regular expressions, the PCRE used in PHP supports recursive matching (`(?R)`).
KennyTM