Hi What is the character for "NOT LIKE" in regex? My problem is that when I retrieve data from mysql I'll have to replace all linebreaks with "<br/>" but it also adds line breaks on please that it shouldn't for example here: <table> <br/><tr> <br/><td> <br/>.... PHP: So either somebody here helps me with an all-occasions solution or I'll have to specify the exact places where "<br/>" shouldn't be added. this works and adds an "<br/>" to every linebreak: $value = preg_replace("/\r/", "<br/>", $value); I tried this but it didn't work: $value = preg_replace("/\r!(>\r)/", "<br/>", $value);
first, let's clear something up. a '<br/>' tag IS a linebreak. '\r\n' however is a carriage return (or CRLF, or new line). if your mysql data has '\r\n' repeatedly in it, and you intend to show output this in a browser, you don't need to worry, as even though the sourcecode will reflect the newlines, they won't appear in the final parsed html output (in your browser window). so why exactly is it you need to do this - are you trying to clean up the source code output? anyway if you must, you could try (untested) $value = preg_replace("/[^>\r]\n?/", "<br/>", $value); PHP: either way you get the idea that you negate character classes with [^<characters here>].