⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 string.html

📁 ajax开发框架prototype中文说明帮助
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<DT><B>返回:</B><DD>返回一个字符值,该字符位于指定索引位置。字符串中的第一个字符的索引为 0,第二个的索引为 1,等等。超出有效范围的索引值返回 undefined。 <p><b>Example:</b></p><pre>var myString = "Hello World!!";document.write( myString.charAt( 1 ) + "&lt;br>" );     //result: edocument.write( myString.charAt( 6 ) + "&lt;br>" );     //result: Wdocument.write( myString.charAt( 12 ) + "&lt;br>" );    //result: !</pre></DL>
</DD>
</DL>
<HR>

<A NAME="charCodeAtTest(int)"><!-- --></A><H3>
charCodeAtTest</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>charCodeAtTest</B>(int&nbsp;index)</PRE>
<DL>
<DD>返回指定字符的 Unicode 编码。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>index</CODE> - 索引号
<DT><B>返回:</B><DD>返回一个字符值,该字符位于指定索引位置。字符串中的第一个字符的索引为 0,第二个的索引为 1,等等。超出有效范围的索引值返回 undefined。 <p><b>Example:</b></p><pre>  var str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";  var s;  alert(str.charCodeAt(0));     //result: 65。 (字符A的ascii码即65)</pre></DL>
</DD>
</DL>
<HR>

<A NAME="concat(net.conic.prototype.String)"><!-- --></A><H3>
concat</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>concat</B>(<A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A>&nbsp;string2)</PRE>
<DL>
<DD>返回一个 String 对象,该对象包含了两个提供的字符串的连接
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>string2</CODE> - 
<DT><B>返回:</B><DD>this + string2 <p><b>Example:</b></p><pre>  var str = "123";  alert(str.concat("456"));     //result: 123456</pre></DL>
</DD>
</DL>
<HR>

<A NAME="fromCharCode(int...)"><!-- --></A><H3>
fromCharCode</H3>
<PRE>
public static <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>fromCharCode</B>(int...&nbsp;numbers)</PRE>
<DL>
<DD>从一些 Unicode 值中回一个字符串。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>numbers</CODE> - 变长参数
<DT><B>返回:</B><DD>根据传入的Unicode值返回字符串 <p><b>Example:</b></p><pre>  alert(String.fromCharCode(112, 108, 97, 105, 110));   //显示:plain </pre></DL>
</DD>
</DL>
<HR>

<A NAME="indexOf(net.conic.prototype.String, int)"><!-- --></A><H3>
indexOf</H3>
<PRE>
public int <B>indexOf</B>(<A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A>&nbsp;substring,
                   int&nbsp;startIndex)</PRE>
<DL>
<DD>返回 String 对象内第一次出现子字符串的字符位置。从左向右开始查找,与lastIndexOf()方向相反。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>substring</CODE> - 子字符串<DD><CODE>startIndex</CODE> - 可选的参数,指出在 String 对象内开始查找的索引。如果省略,则从字符串的开始处查找。<br>如果 startindex 是负数,则 startindex 被当作零。如果它比最大的字符位置索引还大,则它被当作最大的可能索引。
<DT><B>返回:</B><DD>返回一个整数值,指出 String 对象内子字符串的开始位置。如果没有找到子字符串,则返回 -1。  <p><b>Example:</b></p><pre>        var myString = "returns the index of the first";        alert( myString.indexOf( "the" ) );           //8        alert( myString.indexOf( "the", 14 ));    //21 </pre></DL>
</DD>
</DL>
<HR>

<A NAME="lastIndexOf(net.conic.prototype.String, int)"><!-- --></A><H3>
lastIndexOf</H3>
<PRE>
public int <B>lastIndexOf</B>(<A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A>&nbsp;substring,
                       int&nbsp;startIndex)</PRE>
<DL>
<DD>返回 String 对象内第一次出现子字符串的字符位置。从右向左开始查找,与indexOf()方向相反.
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>substring</CODE> - 子字符串<DD><CODE>startIndex</CODE> - 可选的参数,指出在 String 对象内开始查找的索引。如果省略,则从字符串的开始处查找。<br>如果 startindex 是负数,则 startindex 被当作零。如果它比最大的字符位置索引还大,则它被当作最大的可能索引。
<DT><B>返回:</B><DD>返回一个整数值,指出 String 对象内子字符串的开始位置。如果没有找到子字符串,则返回 -1。</DL>
</DD>
</DL>
<HR>

<A NAME="match(net.conic.prototype.Object)"><!-- --></A><H3>
match</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/Array.html" title="net.conic.prototype 中的类">Array</A> <B>match</B>(<A HREF="../../../net/conic/prototype/Object.html" title="net.conic.prototype 中的类">Object</A>&nbsp;regExp)</PRE>
<DL>
<DD>使用正则表达式对象对字符串进行查找,并将结果作为数组返回。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>regExp</CODE> - 描述要查找的内容的一个正则表达式对象
<DT><B>返回:</B><DD>将返回一个数组。<br> 此处对JScript文档中的描述加以补充,并详细举例加以说明.<br> &nbsp;&nbsp;&nbsp;&nbsp;如果没有设置全局标志 (g),数组的第 0 元素包含整个匹配,而第 1 到 n 元素包含了匹配中曾出现过的任一个子匹配;<br> &nbsp;&nbsp;&nbsp;&nbsp;如果有设置全局标志(g),元素 0 到 n 中依次包含所有匹配; <p><b>Example:</b></p><pre>         var r, re;          var s = "The qu1sick b2sickrown f3sickox ju4sickmped o5vicker the lazy yellow dog. fox two";          //没有设置全局标志,也没有子匹配: 1sick          var r1 = s.match(/\dsick/i);          alert(r1);          //没有设置全局标志,但有子匹配: 1sick,1s,ick          var r2 = s.match(/(\ds)(ick)/i);          alert(r2);          //有设置全局标志: 1sick,2sick,3sick,4sick          var r3 = s.match(/(\ds)(ick)/ig);          alert(r3);  </pre></DL>
</DD>
</DL>
<HR>

<A NAME="replace(net.conic.prototype.Object, net.conic.prototype.String)"><!-- --></A><H3>
replace</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>replace</B>(<A HREF="../../../net/conic/prototype/Object.html" title="net.conic.prototype 中的类">Object</A>&nbsp;regExp,
                      <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A>&nbsp;replaceText)</PRE>
<DL>
<DD>返回根据正则表达式进行文字替换后的字符串的复制,但不影响实例本身。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>regExp</CODE> - 描述要查找的内容的一个正则表达式对象<DD><CODE>replaceText</CODE> - 是一个String 对象或文字,对于字符串中每个匹配 rgExp 中的位置都用该对象所包含的文字加以替换。
<DT><B>返回:</B><DD>完成了所有替换的对象的一个复制,但不影响当前对象 <p><b>Example:</b></p><pre>  var s = "The quick brown fox jumped over the lazy yellow dog.";  //The quick brown pig jumped over the lazy yellow dog.  alert(s.replace(/fox/i, "pig"));  //quick The fox brown over jumped lazy the dog. yellow  alert(s.replace( /(\S+)(\s+)(\S+)/g, "$3$2$1"));</pre></DL>
</DD>
</DL>
<HR>

<A NAME="search(net.conic.prototype.Object)"><!-- --></A><H3>
search</H3>
<PRE>
public int <B>search</B>(<A HREF="../../../net/conic/prototype/Object.html" title="net.conic.prototype 中的类">Object</A>&nbsp;regExp)</PRE>
<DL>
<DD>返回与正则表达式查找内容匹配的第一个子字符串的位置,相当于indexOf,但它支持正则表达式匹配查找,功能更加强大。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>regExp</CODE> - 描述要查找的内容的一个正则表达式对象
<DT><B>返回:</B><DD>search 方法指明是否存在相应的匹配。如果找到一个匹配,search 方法将返回一个整数值,指明这个匹配距离字符串开始的偏移位置。如果没有找到匹配,则返回 -1。<br><p><b>Example:</b></p><pre>  var s = "The quick brown fox jumped over the lazy yellow dog.";  alert(s.search(/fox/i));  //位置: 16</pre></DL>
</DD>
</DL>
<HR>

<A NAME="slice(int, int)"><!-- --></A><H3>
slice</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>slice</B>(int&nbsp;start,
                    int&nbsp;end)</PRE>
<DL>
<DD>返回字符串的片段。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>start</CODE> - 必需的;下标以 0 开始的 当前字符串对象 指定部分起始索引。<DD><CODE>end</CODE> - 可选参数;下标以 0 起始的 当前字符串对象 的指定部分结束索引。
<DT><B>返回:</B><DD>slice 方法返回一个包含指定部分的 String 对象。 如果 end 是负数,就表示从 当前字符串对象 结尾开始起算的一个正偏移量。另外,在此意义下,它不是从 0 开始起算的(例如, 如果 end =-1 则表示提取到字符串的结尾)。如果省略 end ,就一直提取到的 当前字符串对象 结尾。 在下面的示例中,slice 方法的两种用法将返回相同的值。 第二个示例中的 -1 指向 str1 中的最后一个字符,并作为提取操作的结束位置: <pre>str1.slice(0)str2.slice(0,-1)</pre></DL>
</DD>
</DL>
<HR>

<A NAME="split(net.conic.prototype.String)"><!-- --></A><H3>
split</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/Array.html" title="net.conic.prototype 中的类">Array</A> <B>split</B>(<A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A>&nbsp;splitText)</PRE>
<DL>
<DD>将一个字符串分割为子字符串,然后将结果作为字符串数组返回。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>splitText</CODE> - 必需的。是一个字符串或正则表达式对象,描述用来定义分解位置的字符。
<DT><B>返回:</B><DD>split 方法的结果是一个字符串数组,对字符串内每个出现 str 的位置都要进行分解。 <p><b>Example:</b></p><pre> var s = "The quick brown fox jumped over the lazy yellow dog.";  // 在每个空格字符处进行分解。The,quick,brown,fox,jumped,over,the,lazy,yellow,dog.  alert(s.split(" "));</pre></DL>
</DD>
</DL>
<HR>

<A NAME="substr(int, int)"><!-- --></A><H3>
substr</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>substr</B>(int&nbsp;startIndex,
                     int&nbsp;length)</PRE>
<DL>
<DD>返回一个从指定位置开始的指定长度的子字符串。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>startIndex</CODE> - 必需的。所需的子字符串的起始位置。字符串中的第一个字符的索引为 0。<DD><CODE>length</CODE> - 可选的。在返回的子字符串中应包括的字符个数。
<DT><B>返回:</B><DD>如果 length 为 0 或负数,将返回一个空字符串。如果没有指定该参数,则子字符串将延续到字符串对象的最后。 <p><b>Example:</b></p><pre>  var s = "The quick brown fox jumped over the lazy yellow dog.";  alert(s.substr(16, 3)); //fox  alert(s.substring(16, 19)); //fox</pre></DL>
</DD>
</DL>
<HR>

<A NAME="substring(int, int)"><!-- --></A><H3>
substring</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>substring</B>(int&nbsp;startIndex,
                        int&nbsp;endIndex)</PRE>
<DL>
<DD>返回一个从指定位置开始的指定长度的子字符串。
<P>
<DD><DL>
<DT><B>参数:</B><DD><CODE>startIndex</CODE> - 可选的。所需的子字符串的起始位置。字符串中的第一个字符的索引为 0。如果没有指定该参数,则为0<DD><CODE>endIndex</CODE> - 可选的。所需的子字符串的结束位置。字符串中的第一个字符的索引为 0。 如果没有指定该参数,取字符串最后一个字符的位置
<DT><B>返回:</B><DD>substring 方法将返回一个包含从原始对象中获得的子字符串的 String 对象。  <p>substring 方法使用 start 和 end 两者的较小值作为子字符串的起始点。例如, strvar.substring(0, 3) 和 strvar.substring(3, 0) 将返回相同的子字符串。 <p>唯一的例外是对负参数的处理。如果第一个参数小于 0,则将作为 0 来处理。而如果第二个参数是负数,则将设置为第一个参数的值。 看示例 <p>该子字符串的长度等于 start 和 end 差的绝对值。例如,在 strvar.substring(0, 3) 和 strvar.substring(3, 0) 返回的子字符串的的长度是 3。 <p>最后,start 和 end 可以是字符串。在这种情况下,如果可能这些字符串将被强制转换为整数。如果不可能,参数的值将作为 0 进行处理。  <p><b>Example:</b></p><pre>  var s = "The quick brown fox jumped over the lazy yellow dog.";  alert(s.substr(16, 3));         //fox  alert(s.substring(16, 19));     //fox  alert(s.substring(19, 16));     //fox  alert(s.substring(16, -1));     //The quick brown     alert(s.substring("16", "19")); //fox  alert(s.substring("aa", "19")); //The quick brown fox</pre></DL>
</DD>
</DL>
<HR>

<A NAME="toLowerCase()"><!-- --></A><H3>
toLowerCase</H3>
<PRE>
public <A HREF="../../../net/conic/prototype/String.html" title="net.conic.prototype 中的类">String</A> <B>toLowerCase</B>()</PRE>
<DL>
<DD>返回一个字符串,该字符串中的字母被转换为小写字母。不影响当前对象的内部状态
<P>
<DD><DL>

<DT><B>返回:</B><DD>返回一个字符串,该字符串中的字母被转换为小写字母。toLowerCase 方法对非字母字符不会产生影响。 <p><b>Example:</b></p><pre>        alert("This is a STRING object".toLowerCase()); //this is a string object</pre></DL>
</DD>
</DL>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -