I want to remove the case sensitivity from emails when searching emails.
For further explanation, If I search an email(dmc@gmail.com) in a different ways like this 'DMC@gmail.com' or 'dMc@gmail.com' or 'Dmc@gmail.com'. I want to retrieve the email. If anyone can help, really appreciated.
Thank you
Just use toLowerCase() in js and you'r done.
let text0 = "abc@gmail.com";
let text1 = "aBc@gmail.com";
let text2 = "ABC@gmail.com";
text0 = text0.toLowerCase();
text1 = text1.toLowerCase();
text2 = text2.toLowerCase();
console.log(text0, text1, text2)
In order to achieve that you could get the text value from the search input and transform it to lowercase before executing the search, you can do that in JS with the method [yourText].toLowerCase()
Example:
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript String to lowercase</h1>
<input id="your-input" type="text">
<button onclick="convertText()">To lowercase!</button>
<p id="demo"></p>
<script>
function convertText() {
let text = document.getElementById("your-input").value;
document.getElementById("demo").innerHTML = text.toLowerCase();
}
</script>
</body>
</html>
As pointed out in the comments, this email lookup operation is actually done by querying an Oracle database.
In this case I would suggest to investigate whether it is possible to execute a query containing a case insensitive WHERE clause to filter on the Email column. I'm not an oracle db expert, but usually database systems allow to perform case insensitive queries, by using the proper collation. At least checkig if this is actually allowed is worth the effort.
By doing so you will get the following advantages:
Another option you can consider, if running a case insensitive query is not supported by your database, is storing the email in a normalized form. You can save both the actual email value (with the original casing) and a normalized version of the email (for instance you can use the email value transformed in uppercase). Then, to perform case insensitive search, you can use the column containing the normalized email value in your WHERE clause. I would suggest to use this approach as a last resort, because you will increase the amount of data stored and you will make your queries less obvious: this is just a workaround to apply when case insensitive queries are not possible.