String对象的方法
|
Function |
Description |
Example |
|
CompareTo() |
Compares one string to another |
("Hello").CompareTo("Hello") |
|
Contains() |
Returns "True" if a specified comparison string is in a string or if the comparison string is empty |
("Hello").Contains("ll") |
|
CopyTo() |
Copies part of a string to another string |
$a = ("Hello World").toCharArray() |
|
EndsWith() |
Tests whether the string ends with a specified string |
("Hello").EndsWith("lo") |
|
Equals() |
Tests whether one string is identical to another string |
("Hello").Equals($a) |
|
IndexOf() |
Returns the index of the first occurrence of a comparison string |
("Hello").IndexOf("l") |
|
IndexOfAny() |
Returns the index of the first occurrence of any character in a comparison string |
("Hello").IndexOfAny("loe") |
|
Insert() |
Inserts new string at a specified index in an existing string |
("Hello World").Insert(6, "brave ") |
|
GetEnumerator() |
Retrieves a new object that can enumerate all characters of a string |
("Hello").GetEnumerator() |
|
LastIndexOf() |
Finds the index of the last occurrence of a specified character |
("Hello").LastIndexOf("l") |
|
LastIndexOfAny() |
Finds the index of the last occurrence of any character of a specified string |
("Hello").LastIndexOfAny("loe") |
|
PadLeft() |
Pads a string to a specified length and adds blank characters to the left (right-aligned string) |
("Hello").PadLeft(10) |
|
PadRight() |
Pads string to a specified length and adds blank characters to the right (left-aligned string) |
("Hello").PadRight(10) + "World!" |
|
Remove() |
Removes any requested number of characters starting from a specified position |
("Hello World").Remove(5,6) |
|
Replace() |
Replaces a character with another character |
("Hello World").Replace("l", "x") |
|
Split() |
Converts a string with specified splitting points into an array |
("Hello World").Split("l") |
|
StartsWith() |
Tests whether a string begins with a specified character |
("Hello World").StartsWith("He") |
|
Substring() |
Extracts characters from a string |
("Hello World").Substring(4, 3) |
|
ToCharArray() |
Converts a string into a character array |
("Hello World").toCharArray() |
|
ToLower() |
Converts a string to lowercase |
("Hello World").toLower() |
|
ToLowerInvariant() |
Converts a string to lowercase using casing rules of the invariant language |
("Hello World").toLowerInvariant() |
|
ToUpper() |
Converts a string to uppercase |
("Hello World").toUpper() |
|
ToUpperInvariant() |
Converts a string to uppercase using casing rules of the invariant language |
("Hello World").ToUpperInvariant() |
|
Trim() |
Removes blank characters to the right and left |
(" Hello ").Trim() + "World" |
|
TrimEnd() |
Removes blank characters to the right |
(" Hello ").TrimEnd() + "World" |
|
TrimStart() |
Removes blank characters to the left |
(" Hello ").TrimStart() + "World" |
|
Chars() |
Provides a character at the specified position |
("Hello").Chars(0) |
String对象的方法的更多相关文章
- JavaScript -- 时光流逝(三):js中的 String 对象的方法
JavaScript -- 知识点回顾篇(三):js中的 String 对象的方法 (1) anchor(): 创建 HTML 锚. <script type="text/javasc ...
- cb18a_c++_修改string对象的方法
cb18a_c++_修改string对象的方法s.insert(p,t)s.insert(p, 'A'); //迭代器前插入As.insert<p,n,t)s.insert(p, 3, 'B') ...
- cb17a_c++_构造string对象的方法
cb17a_c++_构造string对象的方法string sstring s(s2)string s("value")string s(n,'c')string s(b,e) / ...
- JavaScript 字符串(String)对象的方法
anchor() 描述:用于创建 HTML 锚 原型:stringObject.anchor(anchorname) 用法: <script> var txt="Hello wo ...
- JavaScript中String对象的方法介绍
1.字符方法 1.1 charAt() 方法,返回字符串中指定位置的字符. var question = "Do you like JavaScript?"; alert(ques ...
- JavaScript中的string对象及方法
string对象 string对象的两种创建 var a="hello"; var b=new String("hello"); //下面是方法 //charA ...
- [JS]给String对象添加方法,使传入的字符串字符之间以空格分开输出
看到一个这样子的面试题: 给String对象添加一个方法,传入一个string类型的参数,然后将string的每一个字符间加空格返回,例如:addSpace("hello world&quo ...
- 在js中 把 json对象转化为String对象的方法
方法1: 使用js的扩展方法 ** * json对象转字符串形式 */ function json2str(o) { var arr = []; var fmt = function(s) { if ...
- JS支持正则表达式的 String 对象的方法
注意:本文中所有方法的 RegExp 类型的参数,其实都支持传入 String 类型的参数,JS会直接进行字符串匹配. (相当于用一个简单的非全局正则表达式进行匹配,但字符串并没有转换成 RegExp ...
- String 对象-->fromCharCode() 方法
1.定义和用法 将ASCII码转换成对应的字符 语法: String.fromCharCode(n1, n2, ..., nX) 参数: n1, n2, ..., nX:一个或多个 Unicode 值 ...
随机推荐
- DFS:Lake Counting(POJ 2386)
好吧前几天一直没更新博客,主要是更新博客的确是要耗费一点精力 北大教你数水坑 最近更新博客可能就是一点旧的东西和一些水题,主要是最近对汇编感兴趣了嘻嘻嘻 这一题挺简单的,没什么难度,简单深搜 #inc ...
- Java删除文件夹和文件
转载自:http://blog.163.com/wu_huiqiang@126/blog/static/3718162320091022103144516/ 以前在javaeye看到过关于Java操作 ...
- CodeForces - 417A(思维题)
Elimination Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit ...
- POJ 3904 Sky Code (容斥原理)
B - Sky Code Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- css3学习总结5--CSS3文本效果
CSS3 文本效果 1. text-shadow 2. word-wrap text-shadow属性使用方法 text-shadow属性使用方法如下所示. text-shadow:length le ...
- [译]SQL Server 之 查询优化器
因为生成查询计划的代价比较大,所以查询计划将会被缓存. 树形结构 SQL 查询首先被转化为树形结构,每个节点都是一个查询操作.例如: SELECT * FROM Customers C INNER J ...
- linux中使用top获取进程的资源占用信息
在linux中使用top获取进程的资源占用信息: Cpu(s): 1.0%us, 0.0%sy, 0.0%ni, 98.3%id, 0.7%wa, 0.0%hi, 0.0%si, 0.0 ...
- SU Demo之02Filtering--01Sufilter
欢迎各位网友批评指正! 今天博文例子位于如下目录: 第一个脚本: 下面是显示结果: 第二个脚本: 运行结果如下: 第三个脚本: 第四个脚本: 第五个脚本: 最后看看sumute命令的说明:
- "回复 集赞" 抢 《Apple Watch 苹果开发教程》活动开始了!!!
"回复 集赞" 抢 <Apple Watch 苹果开发教程>活动开始了!!! 活动方式: 回复积赞 第1步:回复该帖 扫描二维码进入活动现场 第2步:召集你的小 ...
- COPIED VALUE 的本质意义
定义一个值对象类型,使其实例是可复制的.当它用来和另一个线程通信时,确保复制该值. 此模式主要用于解决在多线程中没有必要进行同步的数据对象的传递——使用值传递方式,即可复制. 故没有加锁开销,每一个副 ...