How would I make the following case insensitive?
if ($(this).attr("href").match(/\.exe$/))
{
// do something
}
In Java, by default, the regular expression (regex) matching is case sensitive.
Case insensitive matching is most frequently used in combination with the Windows file systems, which can store filenames using upper and lowercase letters, but do not distinguish between upper and lowercase characters when matching filenames on disk.
case insensitive (not comparable) (computer science) Treating or interpreting upper- and lowercase letters as being the same.
Put an i
after the closing slash of the regex.
So your code would look like this:
if ($(this).attr("href").match(/\.exe$/i))
With /i
modifier:
if ($(this).attr("href").match(/\.exe$/i))
{
// do something
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With