This pair of functions provide a quick way of testing whether one string starts or ends with another string. Usage: endsWith('Garden', 'en', true) // Returns true startsWith('Garden', 'gard', false) // Returns false function startsWith(str1, str2, matchCase) { if (str1.length < str2.length) return false; if (matchCase) { return (str1.substr(0, str2.length) == str2); } else { return (str1.toLowerCase().substr(0, str2.length) == str2.toLowerCase()); } } function endsWith(str1, str2, matchCase) { if (str1.length < str2.length) return false; if (matchCase) { return (str1.substr(str2.length) == str2); } else { return (str1.toLowerCase().substr(str2.length) == str2.toLowerCase()); } }
| Attributes | Values |
|---|
| rdfs:label
| - Check If String Starts Or Ends With Another String
|
| rdfs:comment
| - This pair of functions provide a quick way of testing whether one string starts or ends with another string. Usage: endsWith('Garden', 'en', true) // Returns true startsWith('Garden', 'gard', false) // Returns false function startsWith(str1, str2, matchCase) { if (str1.length < str2.length) return false; if (matchCase) { return (str1.substr(0, str2.length) == str2); } else { return (str1.toLowerCase().substr(0, str2.length) == str2.toLowerCase()); } } function endsWith(str1, str2, matchCase) { if (str1.length < str2.length) return false; if (matchCase) { return (str1.substr(str2.length) == str2); } else { return (str1.toLowerCase().substr(str2.length) == str2.toLowerCase()); } }
|
| dcterms:subject
| |
| abstract
| - This pair of functions provide a quick way of testing whether one string starts or ends with another string. Usage: endsWith('Garden', 'en', true) // Returns true startsWith('Garden', 'gard', false) // Returns false function startsWith(str1, str2, matchCase) { if (str1.length < str2.length) return false; if (matchCase) { return (str1.substr(0, str2.length) == str2); } else { return (str1.toLowerCase().substr(0, str2.length) == str2.toLowerCase()); } } function endsWith(str1, str2, matchCase) { if (str1.length < str2.length) return false; if (matchCase) { return (str1.substr(str2.length) == str2); } else { return (str1.toLowerCase().substr(str2.length) == str2.toLowerCase()); } }
|