Using regex in preg_replace to match an html href anchor tag?

You don't need to manually replace anything. If this is your whole input string, then use html_entity_decode() to turn the escapes back into and.

You don't need to manually replace anything. If this is your whole input string, then use html_entity_decode() to turn the escapes back into . Again, your regex works as intended with the sample text.

Your problem is the premature mysql_real_escape_string() call. It adds backslashes to the " double quotes in your html, and that's why back-converting fails (your regex is not prepared for finding \"). Avoid that.

Get rid of the ugly clean_string() hack and magic_quotes as advised by the manual. You must do the database escaping right before inserting into the database, not earlier. (Or better yet use the easier PDO with prepared statements.) Also avoid the $newString123 variable duplicates, just overwrite the one you already have when rewriting strings.

– mario Jun 23 at 21:13 It doesn't work.... – Yelneerg Jun 23 at 21:18 The code does work. I tried it out. Please precisise your question.

– mario Jun 23 at 21:21 You tried $newString = preg_replace('#(^&*)#','$2',$string); and it worked? – Yelneerg Jun 23 at 21:25.

You could also do it like this: $str = "DISPLAY_TEXT"; echo "Your html code is thus: " . Htmlspecialchars_decode($str).

That would be fine is that was my whole string but I want to be able to take several paragraphs with any variation of possible markup and match only hrefs – Yelneerg Jun 23 at 21:06.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions