Forum Moderators: coopster

Message Too Old, No Replies

get a part of string from a string

get a part of string from a string

         

xbl01234

1:59 am on Mar 1, 2008 (gmt 0)

10+ Year Member



Hello;
I'd like to ask you how i can get a part of string out from a string by using regular expression, please.

i known how to do it by using substr(), but i think it may be have a better way than using substr().

I got a string as following:
$string="
this is part 1 of the string

<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/6ZRax870WxQ"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/6ZRax870WxQ" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>

this is a part 3 of a string";

and i want to get a part of string out from the above string, so the following result is what i want:

<object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/6ZRax870WxQ"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/6ZRax870WxQ" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>

Thanks

coopster

6:59 pm on Mar 1, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I often use the Perl-compatible regular expressions [php.net] to perform these duties. One of my favorite features in perl is the ease of text extraction and manipulation. In this case you would develop your pattern and capture it for later use.

xbl01234

8:13 pm on Mar 1, 2008 (gmt 0)

10+ Year Member



Thanks a lot