Jump to content

Help with preg_match() function


jjmusicpro

Recommended Posts

I have this in the html:

 

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

 

I am trying to use preg_match to just get "Joes Cool Name" out of it, but keep getting blank values...

Here is what I have..thanks for any help guys... im new to preg_match function :)

 

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

Link to comment
Share on other sites

Ok cool, here is one i tried doing myself, but having same problems.

 

HTML -

<div class="mfsm">Email:</div></td><td valign="top"><div class="mfsm"><a href="mailto:Array">myemail@gmail.com</a></div>

 

Here is what i have, but its blank..

preg_match('|mail([^\<]*)<\/div><\/td><td valign=\"top\"><div class=\"mfsm\">([^\<]*)<|', $result, $email);

Link to comment
Share on other sites

So if i have <div class="mfsm">Email:</div></td><td valign="top"><div class="mfsm"><a href="mailto:Array">myemail@gmail.com</a></div>

 

I want it to give me anything within the <div class="mfsm"></div>

 

Now sometimes there might be an image in there like <div class="mfsm"><img src="/something/joe.jpg"></div> so i want that full thing "<img src="/something/joe.jpg">" thats what my reg exp tried to do before.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.