一次 replace只能替换一个,例如:
var str = 'test test test test'
console.log(str.replace('test', 'tester'))
通过正则可以一下替换全部:
someString = 'the cat looks like a cat';
anotherString = someString.replace(/cat/g, 'dog');
// anotherString now contains "the dog looks like a dog"
更多参考:http://www.tizag.com/javascriptT/javascript-string-replace… Read More
PHP extensions in JavaScript
项目地址:https://github.com/kvz/locutus
直接下载:php.js
npm 安装
npm install locutus
Use
vim index.js
var sprintf = require('locutus/php/strings/sprintf')
var echo = require('locutus/php/strings/echo')
var effectiveness = 'futile'
echo(sprintf('Resistance is %s', effectiveness))
var strings = require(… Read More
项目:https://github.com/adamwdraper/Numeral-js
下载:https://github.com/adamwdraper/Numeral-js/zipball/master
直接下载:Numeral-js.zip
用法 Use it
1. 直接引入,或者CDN引入。
<script src="numeral.min.js"></script>
or include from cdnjs.com
<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/2.0.6/numeral.min.js">&… Read More
rainbowJSON is a jQuery based JSON formatting and syntax Highlighting plugin to make your JSON objects & strings collapsible, colorful and more user readable.
项目地址:https://github.com/Stanko/jquery.rainbowJSON
直接下载: jQuery-Plugin-For-JSON-Syntax-Highlighting-Formatting-rainbowJSON
方法1:使用rainbowJSON插件 How to use it:
1. 引入css文件… Read More