feha Posted May 9, 2010 Share Posted May 9, 2010 Hi the code is below <div class="item_image"><img src="images/sample1.gif" alt="14 Tips for "Crate Training" Your New Puppy"/></div> I can't fix regex to remove quotes within quotes as I'm parsing a content before output ... The situation above will produce invalid xhtml ... I ned to replace quotes between quotes or remove them in order to get valid html ... replacement could be "e; ow no quote at all if within quotes ... Thank you in advance Quote Link to comment https://forums.phpfreaks.com/topic/201146-double-quotes-within-double-quotes-regex-need-help/ Share on other sites More sharing options...
feha Posted May 9, 2010 Author Share Posted May 9, 2010 I have tried this: $content = preg_replace( '/(title|alt)="([^>]*)"/is', '\\1="'.str_replace('"','"e;','\\2').'"', $content ); but it does not replace quotes within $2 variable ... :-( Quote Link to comment https://forums.phpfreaks.com/topic/201146-double-quotes-within-double-quotes-regex-need-help/#findComment-1055317 Share on other sites More sharing options...
feha Posted May 9, 2010 Author Share Posted May 9, 2010 I fixed ... preg_replace needs e modifier at the end ... Quote Link to comment https://forums.phpfreaks.com/topic/201146-double-quotes-within-double-quotes-regex-need-help/#findComment-1055372 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.