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 值 ...
随机推荐
- BestCoder13 1001.Beautiful Palindrome Number(hdu 5062) 解题报告
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5062 题目意思:给出 N,找出 1 - 10^N 中满足 Beautiful Palindrome N ...
- 【USACO】beads
题目: You have a necklace of N red, white, or blue beads (3<=N<=350) some of which are red, othe ...
- 在Win8中创建热点,共享网络
在Win8中创建热点,共享网络 办公室中,我独享10M光纤,没什么要下的,便想利用来更新下Ipad里面的程序,下点公开课.那在不利用软件[用很多wifi共享的软件],从win7开始 系统本身就自带相关 ...
- FreeMarker备忘
以下内容全部是网上收集: FreeMarker的模板文件并不比HTML页面复杂多少,FreeMarker模板文件主要由如下4个部分组成: ,文本:直接输出的部分 ,注释:<#-- ... --& ...
- php 字符串处理
<?php $a = " n001|n002|n003|n004 "; //echo strlen($a);//取字符串的长度 //var_dump(strcmp(" ...
- md5sum 生成 经md5加密后的字符串
➜ ~ echo -n 'admin' | md5sum 21232f297a57a5a743894a0e4a801fc3 - ➜ ~ md5sum -h md5sum: invalid option ...
- Android中JNI 的一些常用Method说明
Android JNI和NDK关系 1.什么JNI Java Native Interface (JNI)标准是java平台的一部分,它允许Java代码和其他语言写的代码进行交互.JNI 是本地编程 ...
- loj 1021(状压dp+记忆化搜索)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=25887 题目大意:给定的一个某进制下的排列,问它的全排列有多少个能 ...
- 电赛菜鸟营培训(四)——STM32F103CB之ADC转换
一.ADC概念 实现模拟信号转换成数字信号就是这样子= = 二.代码框架 #include "stm32f10x.h" void delay(u32 kk) { while(kk- ...
- 【HTML5】Web Workers
什么是 Web Worker? 当在 HTML 页面中执行脚本时,页面的状态是不可响应的,直到脚本已完成. web worker 是运行在后台的 JavaScript,独立于其他脚本,不会影响页面的性 ...