Jump to content

Using " inside a regex.


CSkovholm

Recommended Posts

Hey experts. :)

 

I'm using file_get_contents to save a html page into a variable called $djdanmark. Inside that html page i have a line, like this:

 

<font class="class_1">Some Text</font>

 

Now what i want do to by regex, is to retrieve the text inside those two tags. But as far as i am concerned, you can't use the " inside a variable in php.. My code looks like this:

 

$pattern = "/<font class="class_1">(.*?)<\/font>/";
preg_match($pattern, $djdanmark, $matches);

echo $matches[1];

 

Can someone help me with this?

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/216264-using-inside-a-regex/
Share on other sites

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.