Bawy
03-06-2003, 08:12 PM
I am cleaning a previous programmers work and am attempting to replace occurences like this:
echo "<form action=\"myform.php\" method=\"post\"><input type=\"Hidden\" name=\"Price\" value=\"".$product["price"]."\">";
Which is just ridiculous to try and make HTML adjustments to.
I would like to make a regex that replaces all occurences of " with ' except when a \ precedes it, in which case it should just drop the slash and leave the quote.
\" becomes "
" becomes '
but \" should not become '
I thought of replacing all \" with some arbitrary unicode charector that would never appear in the code and then replacing " with ' and finally from unicode charctor to " but there must be a better way with regex.
echo "<form action=\"myform.php\" method=\"post\"><input type=\"Hidden\" name=\"Price\" value=\"".$product["price"]."\">";
Which is just ridiculous to try and make HTML adjustments to.
I would like to make a regex that replaces all occurences of " with ' except when a \ precedes it, in which case it should just drop the slash and leave the quote.
\" becomes "
" becomes '
but \" should not become '
I thought of replacing all \" with some arbitrary unicode charector that would never appear in the code and then replacing " with ' and finally from unicode charctor to " but there must be a better way with regex.