Jump to content

Escaping Regex


Mike Solstice

Recommended Posts

Ok, that works if I run it CLI or though phpMyAdmin, but won't if I try it in php

 

$remcomma = "UPDATE top_train SET deaths = replace( replace(field_name, ',', ''), '"', '' )";
mysql_query($remcomma);

 

I assume because of the quotes used in the regex. I tried escaping the "

 

$remcomma = "UPDATE top_train SET deaths = replace( replace(field_name, ',', ''), '\"', '' )";
mysql_query($remcomma);

 

Which broke it altogether. Anyone have any ideas?

 

Thanks!

 

Moved here since that thread was marked as solved & it's more of a PHP issue at this point anyway. Any & all help is greatly appreciated!

Link to comment
https://forums.phpfreaks.com/topic/233691-escaping-regex/
Share on other sites

Sorry, kind of assumed people would go read the thread that quote is linked to ;)

 

I have a MySQL column that was created as VARCHAR and has numeric entries that contain commas. I need to convert that to INT in order to be able to use the data in calculations, but need to strip the commas out before I can convert to INT otherwise it just cuts off at the comma & I loose the rest of the data.

Link to comment
https://forums.phpfreaks.com/topic/233691-escaping-regex/#findComment-1201481
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.