Updatego_membersetusernamereplace (username, & #039; non-Chinese Characters & #039;, & #039; & #039;); I want to replace the database name, replace all the characters in the name that are not numbers, letters, or Chinese characters (that is, remove special characters. What should I do ??? The database is MySQL update go_member set username = replace (username, 'non-Chinese characters ','');
I want to replace the names in the database, as long as the names are not numbers, letters, and Chinese characters (that is, special characters are removed. What should I do ???
The database is MySQL.
Reply content:
Update go_member set username = replace (username, 'non-Chinese characters ','');
I want to replace the names in the database, as long as the names are not numbers, letters, and Chinese characters (that is, special characters are removed. What should I do ???
The database is MySQL.
Mysql Regular Expression Matching. I can test it locally.
update go_member set username= '' where username not REGEXP '[[:alpha:]]|[0-9]|[a-z,A-Z]'
---- Thank you ----
Idea 1 (not recommended): Stupid method: first check all the data, then filter the results (filter non-Chinese characters) data to record the ID of the data, and then update
Idea 2 (recommended): Use the regular expression of SQL, which can also be used in SQL. It depends on the database you are using. the specific database has different syntaxes. It depends on your situation. Google it yourself.
For example, Oracle has four regular expression functions: regexp_like, regexp_replace, regexp_substr, and regexp_instr.
Example:
SelectFrom emp where regexp_like (ename, '^ a [a-z]N $ '); you can find the rows whose names start with a and end with n.
Based on the above solutions, you can explore google by yourself .... Hope to help you.
If PHP is used, it is best to use regular expressions in PHP to match and filter the results. Although MySQL supports regular query statements as mentioned above, the efficiency will be lower.
The Chinese regular expression is:/([u4e00-u9fa5])/u
Then, the regular expression used to filter out non-Chinese characters is:/([^u4e00-u9fa5])/u
Provide a Chinese character regular expression in php UTF-8.
P: lowercase matches Chinese characters, and P: uppercase matches non-Chinese characters.