UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

97 lines (74 loc) 2.83 kB
<!-- Generated by Rakefile:build --> <strong> <a href="http://an3m1.com/" rel="nofollow">???? ????</a> </strong> on 2012-04-10 09:54:07 <br /> Write more, that’s all I have to say. Literally, it seems as though you relied on the video to make your point. You clearly know what you’re talking about, why waste your intelligence on just posting videos to your blog when you could be giving us something enlightening to read <hr /> <strong> <a href="test" rel="nofollow">test test</a> </strong> on 2011-07-05 12:23:28 <br /> <pre><code> your_stuff('here'); </code></pre> <hr /> <strong> archive0001 </strong> on 2011-03-04 22:44:11 <br /> this function has a bug. the <pre><code> search += '';</code></pre> at line 28 will destroy the param <pre><code>search</code></pre> as an array. You should add a condition like <pre><code>if (!(search instanceof Array))search += '';</code></pre> <hr /> <strong> Monski </strong> on 2011-02-22 06:11:30 <br /> if you want to replace certain words only.. tweak line 63 <pre><code> reg = new RegExp(&quot;\\b&quot;+escapeRegex(search[i]) + &quot;\\b&quot;, 'gi'); //reg = new RegExp(escapeRegex(search[i]), 'gi'); </code></pre> sample = str_ireplace('H', 'Hi', 'H HeLLo'); will retur &quot;Hi Hello&quot; <hr /> <strong> Leandro Angelo </strong> on 2010-07-22 22:51:23 <br /> Boa funciona legal, e igual o str_ireplace do PHP <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2009-10-09 11:15:31 <br /> @ Philipp Lenssen: Great find! Fixed it. thanks a lot! <hr /> <strong> <a href="http://www.coverbrowser.com" rel="nofollow">Philipp Lenssen</a> </strong> on 2009-10-07 08:22:21 <br /> (My suggested fix should work fine, the &quot;&gt;&quot; problem was something else...) <hr /> <strong> <a href="http://www.coverbrowser.com" rel="nofollow">Philipp Lenssen</a> </strong> on 2009-10-07 08:11:01 <br /> This doesn't seem to escape special regex characters, hence it doesn't work when replacing e.g. &quot;$&quot; with &quot;foo&quot;, or am I missing something&quot;. The following function might help, though I still ran into problems with replacing &quot;&gt;&quot;... <pre><code> Misc.escapeRegex = function(s) { return s.replace(/([\\\^\$*+[\]?{}.=!:(|)])/g, '\\$1'); } </code></pre> <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-03-23 11:07:55 <br /> @ penutbutterjelly: I can see why that looks weird. It's because the code was made by different people though. But I've adjusted str_ireplace to match the behaviour of it's brother str_replace. Thanks for noticing! <hr /> <strong> penutbutterjelly </strong> on 2008-03-21 23:43:46 <br /> Why the zchmook doesn't this one support arrays as input, your str_replace does :/ <hr />