有没有一种简单的方法可以将 MySQL 数据转换为 Title Case? [英] Is there a simple way to convert MySQL data into Title Case?

查看:39
本文介绍了有没有一种简单的方法可以将 MySQL 数据转换为 Title Case?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 MySQL 表,其中一列中的所有数据都以大写形式输入,但我需要转换为标题大小写,并识别类似于 大胆的火球标题案例脚本.

I have a MySQL table where all the data in one column was entered in UPPERCASE, but I need to convert in to Title Case, with recognition of "small words" akin to the Daring Fireball Title Case script.

我发现了这个优秀的解决方案 用于将字符串转换为小写,但 Title Case 函数似乎已被排除在我的 MySQL 版本之外.有没有一种优雅的方法来做到这一点?

I found this excellent solution for transforming strings to lowercase, but the Title Case function seems to have been left out of my version of MySQL. Is there an elegant way to do this?

推荐答案

哇!我根本不擅长 SQL;这是对我有用的方法:

Woo! I'm not handy with SQL at all; Here's the method that worked for me:

  1. 将表导出为 .sql 格式的文本文件.
  2. Textmate(我已经手头上)中打开文件.
  3. 选择包含大写数据的行.
  4. 从文本"菜单中选择转换",然后选择到标题框".
  5. 查找并替换以下各项的每个实例:

  1. Export the table as a text file in .sql format.
  2. Open the file in Textmate (which I already had handy).
  3. Select the rows with UPPERCASE data.
  4. Choose "Convert" from the "Text" menu, and select "to Titlecase".
  5. Find and replace each instance of:

INSERT INTO `Table` (`Col1`, `Col2`, `Etc`, ...) VALUES

使用正确的小写值.

我之前没有尝试使用 Textmate 的原因是我无法弄清楚如何在不破坏其他数据的情况下将单个列转换为 Title Case,但这种方法似乎有效.感谢您的指导和支持!

The reason I didn't try using Textmate before was that I couldn't figure out how to convert a single column to Title Case without ruining the other data, but this method seems to work. Thanks for your guidance and support!

这篇关于有没有一种简单的方法可以将 MySQL 数据转换为 Title Case?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆