How to check if string contains Latin characters only with JavaScript?

Sometimes, we want to check if string contains Latin characters only with JavaScript.

In this article, we’ll look at how to check if string contains Latin characters only with JavaScript.

How to check if string contains Latin characters only with JavaScript?

To check if string contains Latin characters only with JavaScript, we use a regex.

For instance, we write

if (str.match(/[a-z]/i)) {
  // ...
}

to check if string str has only a to z in a case insensitive manner.

We call match to find any matches with this pattern.

Conclusion

To check if string contains Latin characters only with JavaScript, we use a regex.