Navigate back to the homepage

How to find lowercase letters in a string javascript?

Infinitbility
JavaScript
May 23rd, 2022 · 1 min read

Hi Friends 👋,

Welcome To Infinitbility! ❤️

Today, we are going to do how I find lowercase letters in a string, here we will use some common regex to find all lowercase letters from a string.

Here, we will learn to check whether lowercase letter contains in string or not also, and if contain it will return as a string and array format.

  • To remove lowercase letters from the string we will use the javascript replace() method and it will return the rest lowercase letter in the type of string.

  • To find the lowercase letter in string and return it in the form array we will use the javascript match() method.

Let’s plan out what we are going to do in this tutorial.

  1. Find lowercase letters and get them in string
  2. Find lowercase letters and get in array

Let’s start today’s tutorial How to find lowercase letters in a string javascript?

Find lowercase letters and get in the string

In this example, To find lowercase letters we will use regex and javascript replace() method.

1const str = "InfinitBility";
2
3const upperStr = str.replace(/[A-Z]/g, '');
4console.log(upperStr); // 👉️ 'nfinitility'

In the above example, we replace uppercase letters with empty and return the rest strings.

The Output should show nfinitility only. let’s check it.

javascript, find lowercase letters in a string example
javascript, find lowercase letters in a string example

Find lowercase letters and get in array

In this example, To find lowercase letters we will use the regex and javascript match() method to get the rest string in an array.

1const str = "InfinitBility";
2
3const upperStrArr = str.match(/[^A-Z]/g, '');
4console.log(upperStrArr); // 👉️ [ 'n', 'f', 'i', 'n', 'i', 't', 'i', 'l', 'i', 't', 'y' ]

In the above example, we find lowercase letters in the string and returning char in the array.

The Output should show [ 'n', 'f', 'i', 'n', 'i', 't', 'i', 'l', 'i', 't', 'y' ] only. let’s check it.

javascript, find lowercase letters in a string example
javascript, find lowercase letters in a string example

I hope it’s help you, All the best 👍.

Follow me on Twitter

Join our email list and get notified about new content

No worries, I respect your privacy and I will never abuse your email.

Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.

Looking For React Native Tutorial?

we are trying to create the best Tutorial for react native developers.

When you want a daily updates about React Native Tutorial or infinitbility update subscribe to our newsletter.

Read React Native Tutorial

Request New Tutorial or Article on mail [email protected]

Guide book

Guidebook: The Javascript Monorepo Photoshop Guide

Tutorials

Categories

More articles from Infinitbility

How to find and remove object from array in javascript?

Example of find and remove object from array in javascript with step by step guide.

May 22nd, 2022 · 1 min read

How to find common elements in two arrays javascript?

Example of find common elements in two arrays in javascript with step by step guide.

May 22nd, 2022 · 1 min read
© 2020–2022 Infinitbility
About
Link to $https://medium.com/infinitbilityLink to $https://www.facebook.com/InfinitbilityLink to $https://github.com/infinitbilityLink to $https://twitter.com/infinitbilityLink to $https://www.buymeacoffee.com/infinitbilityLink to $mailto:[email protected]