Jump to content

Need help with two regexes - prob quite simple but I'm stumped - 6am tho :(


CptnChainsaw

Recommended Posts

Hi all, I've been programming perl for a couple of years and I'm doing some PHP5 at the moment.  I have a problem with two of my regexes:

 

This regex:

 

$this->_html = preg_replace('<head>', '<head><style type="text/css">enlarge {color:#FF00FF;}</style>', $this->_html);

 

Produces:

 

<<head><style type="text/css">enlarge {color:#FF00FF;}</style>>

</<head><style type="text/css">enlarge {color:#FF00FF;}</style>>

 

It should produce:

 

<head><style type="text/css">enlarge {color:#FF00FF;}</style>

</head>

 

 

 

The second regex is:

 

$html = preg_replace("$keywords[0]",'<span id="enlarge">$keywords[0]<[\/]span>', $html);

 

which produces:

 

Warning: preg_replace() [function.preg-replace]: Delimiter must not be alphanumeric or backslash in e:\free1\testacc\class.Highlighter.php on line 8

 

 

The above code is line 8.  I have tried many variations but I'm having no luck.  Also the second regex uses an array but before I loop over the array I want to get the regex working.

 

 

How can I get these working?

 

 

Cheers in advance for any help.

 

 

CptnChainsaw

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.