2019独角兽企业重金招聘Python工程师标准>>>

原文地址:http://www.yiibai.com/prototype/prototype_string_processing.html

Prototype 字符串处理:方法操作使用例子 - 学习如何操纵DOM和AJAX使用Prototype JavaScript框架.Prototype提高了一个有用的方法,从琐碎的一系列复杂的String对象.

这里是所有函数列表,字符串处理的例子.

Prototype字符串方法:

注: 确保你有至少1.6版本的的prototype.js.

Methods Description
blank() 检查是否该字符串是“空白”,意思是空的或含有唯一的空白.
camelize() 转换成驼峰相当于由破折号分隔的字符串。例如,'foo-bar“将被转换为'fooBar'.
capitalize() Capitalizes the first letter of a string and downcases all the others.
dasherize() Replaces every instance of the underscore character ("_") by a dash ("-").
empty() Checks if the string is empty.
endsWith() Checks if the string ends with substring.
escapeHTML() Converts HTML special characters to their entity equivalents.
evalJSON() Evaluates the JSON in the string and returns the resulting object.
evalScripts() Evaluates the content of any script block present in the string. Returns an array containing the value returned by each script.
extractScripts() Extracts the content of any script block present in the string and returns them as an array of strings.
gsub() Returns the string with every occurrence of a given pattern replaced by either a regular string, the returned value of a function or a Template string.
include() Check if the string contains a substring.
inspect() Returns a debug-oriented version of the string.
interpolate() Treats the string as a Template and fills it with object's properties.
isJSON() Check if the string is valid JSON by the use of regular expressions. This security method is called internally.
parseQuery() Parses a URI-like query string and returns an object composed of parameter/value pairs.
scan() Allows iterating over every occurrence of the given pattern
startsWith() Checks if the string starts with substring.
strip() Strips all leading and trailing whitespace from a string.
stripScripts() Strips a string of anything that looks like an HTML script block.
stripTags() Strips a string of any HTML tag.
sub() Returns a string with the first count occurrences of pattern replaced by either a regular string, the returned value of a function or a Template string.
succ() Used internally by ObjectRange. Converts the last character of the string to the following character in the Unicode alphabet.
times() Concatenates the string count times.
toArray() Splits the string character-by-character and returns an array with the result.
toJSON() Returns a JSON string.
toQueryParams() Parses a URI-like query string and returns an object composed of parameter/value pairs.
truncate() Truncates a string to the given length and appends a suffix to it (indicating that it is only an excerpt).
underscore() Converts a camelized string into a series of words separated by an underscore ("_").
unescapeHTML() Strips tags and converts the entity forms of special HTML characters to their normal form.
unfilterJSON () Strips comment delimiters around Ajax JSON or JavaScript responses. This security method is called internally.

转载于:https://my.oschina.net/prototype1/blog/71347

Prototype 字符串相关推荐

  1. JS字符串常用属性、方法

    文章目录 属性 length constructor prototype 方法 charAt() charCodeAt() concat() indexOf() lastIndexOF() slice ...

  2. 美国主流网站所使用的JavaScript框架

    作者:Pingdom 时间:2008-10-04 来自:翻译 技术等级: 哪些JavaScript框架是最常见,使用最频繁的? 要回答这个问题,我们对大约200个美国主流网站进行了调研,检查他们是否使 ...

  3. 借鉴一些关于js框架的东西

    八款Js框架介绍及比较,Dojo .Scriptaculous .Prototype .yui-ext .Jquery .Mochikit.mootools .moo.fx,componentartu ...

  4. [转载]从受欢迎角度分析哪些美国主流网站使用了哪些JS框架

    哪些JavaScript框架是最常见,使用最频繁的? 要回答这个问题,我们对大约200个美国主流网站进行了调研,检查他们是否使用了JavaScript框架?如果使用,那么他们选用什么样的框架?在这里, ...

  5. JS 面向对象编程之原型(prototype)

    微信小程序开发交流qq群   173683895    承接微信小程序开发.扫码加微信. function Person(first, last) {this.first = first;this.l ...

  6. regexp 好汉字符串_如何在JavaScript中使用RegExp确认字符串的结尾

    regexp 好汉字符串 by Catherine Vassant (aka Codingk8) 由凯瑟琳·瓦森(Catherine Vassant)(又名Codingk8) 如何在JavaScrip ...

  7. 在JavaScript中重复字符串的三种方法

    In this article, I'll explain how to solve freeCodeCamp's "Repeat a string repeat a string" ...

  8. js字符串加密的几种方法

    在做web前端的时候免不了要用javascript来处理一些简单操作,其实如果要用好JQuery, Prototype,Dojo 等其中一两个javascript框架并不简单,它提高你的web交互和用 ...

  9. javascript之prototype总结常用方法

    //去左右空格 String.prototype.trim = function() {     return this.replace(/^\s*|\s*$/g,''); } //去空格添加至数组集 ...

最新文章

  1. 独家 | 降维是数据科学家的必由之路
  2. 以“数”赋能驱动企业转型 美的集团秘诀都在这里
  3. linux中查找某一个字符串,Linux系统下,在文件中查找某个字符串
  4. 解决 QT 发送 HTTP 请求时遇到 qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed 问题
  5. 移动Sql Server数据库的脚本
  6. 程序员求职面试三部曲之三:快速适应新的工作环境
  7. php获取访问者ip地址汇总,php获取访问者IP地址汇总_PHP
  8. 【java web】java执行预编译Groovy脚本
  9. poj 1182 食物链的一种解法(详解),非向量法
  10. 备份文件到本地服务器失败,已解决: 备份index/boostrap ,备份filesystem 失败 - Dell Community...
  11. ios客户端快速滚动和回弹效果的实现
  12. leetcode 181 Employees Earning More Than Their Managers 不会分析的数据库复杂度
  13. vrep系列教程(一)——熟悉vrep
  14. JSAPI微信支付java
  15. mac废纸篓的如何还原?
  16. 简易特效制作ByUnityParticleSystem
  17. 熬夜学Java语言-File类浅解析
  18. 访问Linux服务器新轮子WindTerm使用
  19. ETHEOS 开发资源及工具集合
  20. Jira、confluence和crowd安装文档

热门文章

  1. linux兴趣小组2017面试题浅析
  2. 75. 颜色分类 golang
  3. xpath 简单用法小记
  4. c++模板---3(类模板碰到继承问题,类模板类外实现,类模板与友元函数)
  5. 数据结构(六)二叉树的遍历(递归非递归方法)
  6. 【计算机系统设计】实践笔记(6)改进数据通路:lw和sw指令
  7. Java面试题整理,java常用排序算法图解
  8. border-image图片边框
  9. mysql常用操作(一)
  10. WebAPI 2参数绑定方法