$.string requires jQuery 1.2.2 or later. It may work with earlier versions, but only these have been tested. $.string has been tested with the following web browsers:
- Chrome 11+ (probably works with earlier versions)
- Firefox 2.x, 3.x or 4.x
- Internet Explorer 6, 7, 8 or 9
- Opera 9.5
- Safari 3.x, 4.x, and 5.x
Include jQuery and $.string in your header:
$.string(" ").blank(); // true
All methods that do not return a String will produce the same result as the Prototype counterpart. blank returns boolean, evalJSON returns a JSON object, etc. For methods that do return a string, $.string will return another $.string object. This allows you to chain $.string methods without needing to extend String. You can retrieve the string portion of the object using the ‘str’ property.
this is a test
“).strip().stripTags().capitalize().str // ‘This is a test’
$.string can also be used to extend the String prototype in the same manner that Prototype does, giving you the same functionality and compatibility.
this is a test
“.strip().stripTags().capitalize() // ‘This is a test’
$.string‘s compatibility target is Prototype 22.214.171.124. Latest Prototype version is 126.96.36.199, however this introduced an incompatibility with the toJSON method, so it was decided to maintain 188.8.131.52 compatibility as this is more of a legacy/transition project. All other methods pass their compatibility tests in 184.108.40.206.
Credits and License
jquery.string – Prototype string functions for jQuery
(c) 2008-2014 David E. Still (http://stilldesigning.com)
Original Prototype extensions (c) 2005-2014 Sam Stephenson (http://prototypejs.org)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
(The astute reader will note that this is the same license that Prototype is released under.)