Forum Moderators: coopster

Message Too Old, No Replies

Simplify preg match statements

         

ntbgl

11:58 am on Jul 6, 2009 (gmt 0)

10+ Year Member



When using preg_match, I'm always finding myself writing two lines of code:

preg_match("/start(.*)end/isU",$in,$out);
$out=$out[1];

Is there a way to say that I want the output to be a string?

Thanks

coopster

6:03 pm on Jul 6, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That's common usage. Otherwise you could use preg_replace but only if you are using the entire string in your pattern.