'How to compare two strings case insensitive in Rhino js

I intend to check if a string is a substring of another string. However, case insensitive match is not possible since toLowerCase() and toUpperCase() methods are not supported in Rhino 1.7.13.

var stored_string="{{SSHA1}9BC34549D565D9505B287DE0CD20AC77BE1D3F2C"
var str = "9bc34549d565d9505b287de0cd20ac77be1d3f2c"

I am using indexOf mathod to check for the substring.

if (stored_string.toString().indexOf(str)===0) {
   //do something
}

Is there any good way this comparison is possible case insensitive?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source