Doing some nerding and..
November 21st, 2008
As the title implies I was doing some database cleansing this morning and was trying to craft a cleaver regular expression to remove junk works and characters from my mysql database. I ended up writing a quick PHP script to do the cleanup for me. The actual regex I use removes line feeds, line breaks, and tabs from the database field.
The point is that I found this really handy online regular expression(regex) tool which let’s you test the expression quickly and easily.
here’s that database php code if anyones interested.
for ($i=0; $i<$row_count; $i++)
{
$row = mysql_fetch_row($result);
$row[0] = trim(StripSlashes($row[0]));
$res = preg_replace(”/[[\r\n\t]]/”, “”, $row[0]);
$query2 = “UPDATE `search` SET `text`=\”".AddSlashes($res).”\” WHERE `text`=\”".AddSlashes($row[0]).”\”;”;
$result2 = mysql_query($query2);
}
Popularity: 1% [?]