jString is a javascript library extending String object with frequently needed methods.
Read more @ hmkcode.com.
-
Download the jstring.js
-
Add it in the HTML file
<script src="jstring.js" type="text/javascript" language="javascript"></script>
- Congratulations! your String has more methods
"normal string".contains("t") \\ return true
"normal text".count("t"); \\ return 2
"normal TEXT".capitalize(); \\ return "Normal text"
" normal text ".trim(); \\ return "normal text"
" normal text".leftTrim(); \\ return "normal text"
"normal text ".rightTrim(); \\ return "normal text"
clear: will trim() + remove (+1) white-spaces in between
" normal text ".clear(); \\ return "normal text"
"normal text".startsWith("nor"); \\ return true
"normal text".endsWith("ext"); \\ return true
"normal text".insert("X", 4); \\ return "normXal text"