Jump to content

Simple RegEx with Sample And HTML - Not working :(


jjmusicpro

Recommended Posts

I cant get this to work for some reason... just kicks out blank...

 

Code

preg_match('/<div class=\"c\"><strong>(.*?)<\/strong><\/div>/i', $result, $name);

echo $name[0]. " " .$name[1];

 

I even tried this

preg_match('/<div class=\"c\"><strong>([^\<]*)<\/strong><\/div>/i', $result, $name);

echo $name[0]. " " .$name[1];

 

HTML

<div class="c"><strong>My Cool Name</strong>

 

I want to get "My Cool Name" out of that...

Figured it out, didnt see i had the extra <div> at the end

 

preg_match('/<div class=\"c\"><strong>([^\<]*)<\/strong>/i', $result, $name);

 

I cant get this to work for some reason... just kicks out blank...

 

Code

preg_match('/<div class=\"c\"><strong>(.*?)<\/strong><\/div>/i', $result, $name);

echo $name[0]. " " .$name[1];

 

I even tried this

preg_match('/<div class=\"c\"><strong>([^\<]*)<\/strong><\/div>/i', $result, $name);

echo $name[0]. " " .$name[1];

 

HTML

<div class="c"><strong>My Cool Name</strong>

 

I want to get "My Cool Name" out of that...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.