class Program
{
static void Main(string[] args)
{
// Input strings.
const string s1 = "samuel allen";
const string s2 = "dot net perls";
const string s3 = "Uppercase first letters of all words in the string."; // Write output strings.
Console.WriteLine(TextTools.UpperFirst(s1));
Console.WriteLine(TextTools.UpperFirst(s2));
Console.WriteLine(TextTools.UpperFirst(s3));
Console.ReadKey();
}
} public static class TextTools
{
/// <summary>
/// Uppercase first letters of all words in the string.
/// </summary>
public static string UpperFirst(string s)
{
return Regex.Replace(s, @"\b[a-z]\w+", delegate(Match match)
{
string v = match.ToString();
return char.ToUpper(v[]) + v.Substring();
});
}
}

c# 正则表达式 首字母转大写的更多相关文章

  1. React Native class 后面的命名首字母需要大写

    React Native class 后面的命名首字母需要大写 否则会报Expeted a component class,got [object Object].

  2. ytu 1938:首字母变大写(水题)

    首字母变大写 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 110  Solved: 43[Submit][Status][Web Board] Desc ...

  3. word2013中取消句首字母自动大写

    经常使用word的朋友都知道word中一行的首字母会自动大写,这给用户带来方便的同时,也产生了问题,因为有时候我们并不希望每行开头的首字母大写.要取消首字母自动大写可以取消勾选"首句字母大写 ...

  4. HDOJ2026首字母变大写

    首字母变大写 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Subm ...

  5. struct和[]byte的转换,注意结构体内变量首字母一定大写

    type temp struct {     Afd int     Bee string }func main(){ text:=temp{3123,"4234"} b._:=j ...

  6. YTU 2760: 字符串---首字母变大写

    2760: 字符串---首字母变大写 时间限制: 1 Sec  内存限制: 128 MB 提交: 343  解决: 136 题目描述 输入一行英文句子,将每个单词的第一个字母改成大写字母. 输入 一个 ...

  7. vue踩坑 导出new Vue.Store首字母要大写

    控制台报错  : Uncaught TypeError: vuex__WEBPACK_IMPORTED_MODULE_6__.default.store is not a constructor 根据 ...

  8. Libreoffice/Office:禁止首字母自动大写功能

     造冰箱的大熊猫@cnblogs 2019/1/24 在LibreOffice(5.1.6.2)中,要禁止或者使能首字母自动大写功能,点击菜单项“Tools>>AutoCorrect Op ...

  9. JS对象 Date 日期对象 日期对象可以储存任意一个日期,并且可以精确到毫秒数(1/1000 秒)。 定义一个时间对象 : var Udate=new Date();Date()的首字母须大写

    Date 日期对象 日期对象可以储存任意一个日期,并且可以精确到毫秒数(1/1000 秒). 定义一个时间对象 : var Udate=new Date(); 注意:使用关键字new,Date()的首 ...

随机推荐

  1. pandas数组获取最大值索引的方法-argmax和idxmax

    pandas Series 的 argmax 方法和 idxmax 方法用于获取 Series 的最大值的索引值: 举个栗子: 有一个pandas Series,它的索引是国家名,数据是就业率,要找出 ...

  2. 字符测试与映射函数 ctype.h

    对于C Standard Library 可以参考:http://www.acm.uiuc.edu/webmonkeys/book/c_guide/ 或者 http://www.cplusplus.c ...

  3. 每日英语:The Invasion of the Online Tutors

    It's a nightly dilemma in many households: A student hits a wall doing homework, and parents are too ...

  4. 如何让 zend studio 10 识别 Phalcon语法并且进行语法提示

    让 zend studio 10 识别 Phalcon语法并且进行语法提示 https://github.com/rogerthomas84/PhalconPHPDoc 下载解压后,把里面 phalc ...

  5. godep的save和update

    godep save ./... 把依赖的包从GOPATH里找到,然后固化到当前目录Godeps目录里. 但是它不分版本:如果GOPATH里某个包升级了,godep save不会把它更新到Godeps ...

  6. 搭建kafka源码开发环境时使用"gradle idea"命令构建源码失败

    我的环境: JDK: 1.8.0_131 Gradle: Gradle 3.1 Kafka源码包: kafka-0.10.0.1-src.tgz Zookeeper安装包: zookeeper-3.4 ...

  7. signal函数的原型声明void (*signal(int signo, void (*fun(int))))(int)分析

    转:http://blog.sina.com.cn/s/blog_4850a7880100hnam.html void (*signal(int signo, void (*fun(int))))(i ...

  8. 【转】mysqldump的锁表的问题

    今天凌晨,公司的一台MySQL生产库备份时间从2:30一直备份到8:30,正常情况下这个备份应该只会备份20分钟,3:00之前就会备份完毕,但是这次备份时间太长了,也影响了公司业务的使用.先写一下公司 ...

  9. Lintcode: Fast Power 解题报告

    Fast Power 原题链接:http://lintcode.com/en/problem/fast-power/# Calculate the an % b where a, b and n ar ...

  10. python celery 多work多队列

    1.Celery模块调用 既然celery是一个分布式的任务调度模块,那么celery是如何和分布式挂钩呢,celery可以支持多台不通的计算机执行不同的任务或者相同的任务. 如果要说celery的分 ...