I need to replace the special characters å,ä,ö (with a or o) in my WP database for all image attachments. How can I apply this search and replace only to affect these links?
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.Sign up to join this community
Just do this with your string:
$yourString = preg_replace ( '/å/' , 'a' , $yourString ) $yourString = preg_replace ( '/ä/' , 'a' , $yourString ) $yourString = preg_replace ( '/ö/' , 'o' , $yourString )
If you just want to do it with an SQL sentence, then you can try this :
REPLACE(REPLACE(REPLACE(StringColumn, 'å', 'a') , 'ä', 'a') , 'ö', 'o')
And you can use it in a SELECT, UPDATE, ... sentences, like this:
UPDATE MyTable SET StringColumn = REPLACE(REPLACE(REPLACE(StringColumn, 'å', 'a') , 'ä', 'a') , 'ö', 'o')