如何執行以下操作PHP函數MySQL使用UPDATE
,SET
和REPLACE
?如何刪除MySQL中的字符串中的多個空格,換行,回車和製表符?
preg_replace('/\s+/', ' ', $string);
編輯問題
我OBJECTIF是從如下字符串
[!DOCTYPE html]
[!--[if IE 8]][html class="no-js lt-ie9" lang="es" ][![endif]--]
[!--[if gt IE 8]][!--] [html class="no-js" lang="es" ] [!--[![endif]--]
[html lang="es-ES" prefix="og: http://ogp.me/ns#"]
[head]
去上述
[!DOCTYPE html][!--[if IE 8]][html class="no-js lt-ie9" lang="es" ][![endif]--]
[!--[if gt IE 8]][!--][html class="no-js" lang="es" ][!--[![endif]--][html lang="es-ES" prefix="og: http://ogp.me/ns#"][head]
所有\ r \ n \ t
\ =新線 \ R =回車 \ T =標籤
編輯答案
完整的答案使用UPDATE
ñ結算,SET
和REPLACE
除了Elias Van Ootegem的建議外
UPDATE tab
SET col = REPLACE(
REPLACE(
REPLACE(
REPLACE(col, '~', ''),
'\t', '' -- replace tabs
),
'\n','' -- replace *NIX line-feeds
),
'\r', -- replace DOS line-feeds
''
)
你甚至試過......有這個問題的數以千計的愚蠢:http:// stackoverflow.com/questions/6858143/mysql-how-to-remove-white-space-in-a-mysql-field –
它是沒有我想要的... – RafaSashi
添加的答案,希望這就是你之後 –