将字符串中的每个单词翻译为大写,但有异常 [英] translate each word in string to uppercase with exceptions

查看:86
本文介绍了将字符串中的每个单词翻译为大写,但有异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我想做的是将每个单词的第一个字母用大小写成大小写,除了和 &安培; in


我该怎么做呢?


干杯,

Adam

Hi,

What i want to do is make the first letter of each word in a sting uppercase except "and" & "in"

How would i go about doing this?

Cheers,
Adam

推荐答案

ucwords?大写字符串中每个单词的第一个字符

ucwords ? Uppercase the first character of each word in a string


new_phrase = ucwords(
new_phrase = ucwords (


短语);


然后你需要找到所有的和'和其他你不想改变的东西并改回来:

phrase );

Then you need to find all the and''s and what ever else you don''t want changed and changed them back:


这篇关于将字符串中的每个单词翻译为大写,但有异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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