Categories
JavaScript Answers

How to check for any lowercase letters in a string with JavaScript?

Spread the love

Sometimes, we want to check for any lowercase letters in a string with JavaScript.

In this article, we’ll look at how to check for any lowercase letters in a string with JavaScript.

How to check for any lowercase letters in a string with JavaScript?

To check for any lowercase letters in a string with JavaScript, we use a regex.

For instance, we write

const hasLowerCase = (str) => {
  return /[a-z]/.test(str);
};

to call /[a-z]/.test with str to check if str has any lower case letters.

Conclusion

To check for any lowercase letters in a string with JavaScript, we use a regex.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *