JQuery Remove All Numbers from String Example

By Hardik Savani November 17, 2022 Category : jQuery

Hello Folks,

In this quick example, let's see jquery remove all numbers from string. you can understand a concept of how to remove all numbers from a string in jquery. you'll learn jquery remove all numbers from string. This article goes in detailed on jquery string remove all numbers.

I will give you a very simple and short example of how to remove all numbers from string in jquery. we will use replace function to remove all numbers from text. so, let's run the below html file.

Example:

index.html

<!DOCTYPE html>

<html>

<head>

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>

</head>

<body>

</body>

<script type="text/javascript">

$(document).ready(function () {

myString = "Hi, It 123 SolutionStuff 456";

newString = myString.replace(/\d+/g, '');

console.log(newString);

});

</script>

</html>

Output:

Hi, It SolutionStuff

I hope it can help you...

Tags :
Shares