replace() 所有单词首字母大写
function ReplaceDemo()
{
var r,re;
var s="The quick brown fox jumpe dover the lazy yellow dog.";
re=/\b\w+\b/g;
r=s.replace(re,function(ww){
return "("+ww.slice(0,1).toUpperCase()+ww.slice(1)+")";
}
);
return(r);
}
replace() 所有单词首字母大写的更多相关文章
- 小tips:JS/CSS实现字符串单词首字母大写
css实现: text-transform:capitalize; JS代码一: String.prototype.firstUpperCase = function(){ return this.r ...
- javascript面试题:如何把一句英文每个单词首字母大写?
上周看到大家在JS群讨论如何把一句英文句子单词收割字母大写,大家都说用正则简单,对于正则还是有点模糊,于是乎自己敲了下 //面试题:如何把一句英文每个单词首字母大写? var str="wh ...
- string.capwords() 将每个单词首字母大写
string.capwords() 将每个单词首字母大写 代码: import string s = ' The quick brown fox jumped over the lazy dog. ' ...
- CSS实现英文或拼音单词首字母大写
CSS实现英文或拼音单词首字母大写,只需要在css样式中加入: text-transform: capitalize 即可. 测试代码如下: <!doctype html> <htm ...
- Python 2:str.title()(使字符串每个单词首字母大写)
name = "hello,world! hello,python!" print(name.title()) #单词首字母大写 运行结果将会是:Hello,World!Hello ...
- JS replace()方法-字符串首字母大写
replace() 方法用于在字符串中用一些字符替换另一些字符,或替换一个与正则表达式匹配的子串. replace()方法有两个参数,第一个参数是正则表达式,正则表达式如果带全局标志/g,则是代表替换 ...
- text-transform设置单词首字母大写
text-transform 一.语法 text-transform 主要用于设置文本的大小写. text-transform有5个值,分别如下: none. 默认值. capitalize. 文 ...
- FCC JS基础算法题(4):Title Case a Sentence(句中单词首字母大写)
题目描述: 确保字符串的每个单词首字母都大写,其余部分小写.像'the'和'of'这样的连接符同理. 算法: function titleCase(str) { // 转小写及分割成数组 var st ...
- 吴裕雄 Bootstrap 前端框架开发——Bootstrap 排版:设定单词首字母大写
<!DOCTYPE html> <html> <head> <title>菜鸟教程(runoob.com)</title> <meta ...
随机推荐
- 笨鸟先飞之ASP.NET MVC系列之过滤器(03动作过滤器过滤器)
概念介绍 动作过滤器应该是我们平常工作中需要用到最多的过滤器了,动作过滤器,主要在我们的动作方法执行前后执行. 如果我们需要创建动作过滤器需要实现IActionFilter接口. 我们看到该接口里有两 ...
- 构造函数,This关键字
构造函数: 即构建创造对象时调用的函数.在new的时候自动执行,给对象进行初始化.创建对象都必须要通过构造函数初始化.(有参和无参) 一个类中如果没有定义过构造函数,那么类中会有一个默认的空参数构造函 ...
- CloneZilla + Parkomat 实现网络备份
I. 准备 1. 下载 & 烧录 CloneZilla Live 前往 http://clonezilla.org/downloads.php 下载CloneZilla Live,有四个版本, ...
- Traefik实现Kubernetes集群服务外部https访问
转载请注明出处:http://www.cnblogs.com/wayneiscoming/p/7707942.html traefik 是一个前端http反向代理服务器以及负载均衡器,支持多种微服务后 ...
- 深入Javascript之this
前言 近期准备好好的读一读<你不知道的JavaScript(上卷)>这本书,俗话说的好,好记性不如烂笔头,读到this这章感觉是时候需要一些笔记了.文中如有错误之处,欢迎指出. 什么是th ...
- A low-cost wear-leveling algorithm for block-mappingsolid-state disks
[] Li-Pin Chang,Li-Chun Huang.A low-cost wear-leveling algorithm for block-mapping solid-state disks ...
- LeetCode 79. Word Search(单词搜索)
Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from l ...
- 使用selenium webdriver+beautifulsoup+跳转frame,实现模拟点击网页下一页按钮,抓取网页数据
记录一次快速实现的python爬虫,想要抓取中财网数据引擎的新三板板块下面所有股票的公司档案,网址为http://data.cfi.cn/data_ndkA0A1934A1935A1986A1995. ...
- Swift 之Protocol在cocoa中的使用范例搜集(一)
protocol Reusable: class { static var reuseIndentifier: String {get} static var nib: UINib? {get} } ...
- Leetcode题解(26)
80. Remove Duplicates from Sorted Array II 题目 分析:简单的操作,代码如下: class Solution { public: int removeDupl ...