简体   繁体   English

大写字符串中没有空格的每个单词

[英]Capitalize each word in string that has no spaces

I am trying to figure out if there are existing libraries/methods that would allow you to capitalize each word in a string, however the words have no spaces. 我试图弄清楚是否有现有的库/方法可以让您将字符串中的每个单词都大写,但是单词之间没有空格。 For example: 例如:

"blueparrot" should be converted to "BlueParrot" "blueparrot"应转换为"BlueParrot"

I know that if there were spaces, I can accomplish this with: 我知道如果有空格,我可以使用以下方法完成此操作:

var textInfo = new CultureInfo("en-US", false).TextInfo;
textInfo.ToTitleCase("blue parrot");

However, without the spacing, the outcome is 但是,如果没有间隔,结果是

Blueparrot Blueparrot

对于这个问题,没有简单的解决方案,只能说将2个单词的字符串放在一起,这时您需要提供有关分词位置的信息,或对其进行适当的格式化。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 C# 将每个单词的第一个字符或整个字符串的第一个字符大写? - How to capitalize the first character of each word, or the first character of a whole string, with C#? C# 将字符串中每个句子的首字母大写 - C# Capitalize first letter in in each sentence in a string 替换字符串中用空格括起来的单词的首次出现 - Replacing first occurence of a word enclosed in spaces in a string 在C#中打开Word文档,路径中包含空格 - Opening Word document within C# that has spaces in the path 如果单词之间有更多的空格,如何从字符串中获取第n个单词? - How to get the nth word from a string if there are more spaces between the words? 仅在第一个单词之间用多个空格分隔后才拆分字符串 - Split string only after the first word which is separated by multiple spaces 使用 String.ToUpper() 时程序退出; 在一个有空格的字符串上 - Program exiting when using String.ToUpper(); on a string that has spaces in it 将字符串中的第一个单词单词大写 - Capitalize First Char Of Words in a string 在字符串中的第一个单词之前替换空格,然后删除多余的空格 - replace blank spaces before first word in string, then remove extra blank spaces 用唯一值替换字符串中单词的每个实例 - Replacing each instance of a word in a string with a unique value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM