Scenario:
There's a variable containing something like this: "<aaa><bbb>". The object is to find what's between the first two brackets. In Perl, this could be done like this:
$var="<aaa><bbb>";
$var=~/<(.+?)>/;
$result=$1;
My question is, how is this done in PHP? I know:
$var="<aaa><bbb>";
ereg("<(.*)>", $var, $out);
$result=$out[1];
But * is greedy, so instead of "aaa" it gives "aaa><bbb". I tried replacing (.*) with (.+?) but apparently you can't do that in PHP. So, how do you do it?
There's a variable containing something like this: "<aaa><bbb>". The object is to find what's between the first two brackets. In Perl, this could be done like this:
$var="<aaa><bbb>";
$var=~/<(.+?)>/;
$result=$1;
My question is, how is this done in PHP? I know:
$var="<aaa><bbb>";
ereg("<(.*)>", $var, $out);
$result=$out[1];
But * is greedy, so instead of "aaa" it gives "aaa><bbb". I tried replacing (.*) with (.+?) but apparently you can't do that in PHP. So, how do you do it?