Step 1. First make sure the string has Chinese or non ASCII characters in it:
select asciiname from table1
where asciiname regexp(concat('[',char(128),'-',char(255),']'));
Step 2. If the Chinese name is definitely at the end of your field, you just need to trim the last occurrence of a space in your field. Confirm it is doing the right thing first:
select asciiname, reverse(substring(reverse(asciiname), locate(' ', reverse( asciiname ) )+1))
from table1
where asciiname regexp(concat('[',char(128),'-',char(255),']'));
Step 3. Execute:
update table1
set asciiname = reverse(substring(reverse(asciiname), locate(' ', reverse( asciiname ) )+1))
where asciiname regexp(concat('[',char(128),'-',char(255),']'));
My sources for this were (I am very grateful to):
1. http://stackoverflow.com/questions/461871/find-rows-with-non-ascii-values-in-a-column
2. http://dev.mysql.com/doc/refman/5.1/en/string-functions.html
Programming solutions, source code, solutions to tech problems and other tech related stuff.
Showing posts with label strings. Show all posts
Showing posts with label strings. Show all posts
Friday, November 25, 2011
Sunday, March 13, 2011
ReplaceAll in Javascript Example
ReplaceAll in Javascript Example:
Instead of:
mynicestring = mynicestring.replace("find","replacement");
Use:
mynicestring = mynicestring.replace(/find/g,"replacement");
Instead of:
mynicestring = mynicestring.replace("find","replacement");
Use:
mynicestring = mynicestring.replace(/find/g,"replacement");
Subscribe to:
Posts (Atom)