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

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.