String.js
资源名称:WorkFlow.rar [点击查看]
上传用户:ahit0551
上传日期:2009-04-15
资源大小:2345k
文件大小:1k
源码类别:
xml/soap/webservice
开发平台:
Java
- /**
- * <p>Title: 扩展String</p>
- * <p>Description: </p>
- * <p>Copyright: Copyright (c) xio.name 2006</p>
- * @author xio
- */
- String.prototype.contains = function (A) {
- return (this.indexOf(A) > -1);
- };
- String.prototype.equals = function () {
- for (var i = 0; i < arguments.length; i++) {
- if (this == arguments[i]) {
- return true;
- }
- }
- return false;
- };
- String.prototype.startsWith = function (A) {
- return (this.substr(0, A.length) == A);
- };
- String.prototype.endsWith = function (A, B) {
- var C = this.length;
- var D = A.length;
- if (D > C) {
- return false;
- }
- if (B) {
- var E = new RegExp(A + "$", "i");
- return E.test(this);
- } else {
- return (D == 0 || this.substr(C - D, D) == A);
- }
- };
- String.prototype.remove = function (A, B) {
- var s = "";
- if (A > 0) {
- s = this.substring(0, A);
- }
- if (A + B < this.length) {
- s += this.substring(A + B, this.length);
- }
- return s;
- };
- String.prototype.trim = function () {
- return this.replace(/(^s*)|(s*$)/g, "");
- };
- String.prototype.ltrim = function () {
- return this.replace(/^s*/g, "");
- };
- String.prototype.rtrim = function () {
- return this.replace(/s*$/g, "");
- };
- String.prototype.replaceNewLineChars = function (A) {
- return this.replace(/n/g, A);
- };