04-Apr-2023
.
Admin
Hello friends,
In this blog, i will show you how to remove all spaces from string in reactjs. We will talk about remove all spaces from string example in reactjs. i would like to share with you remove all white space from string in reactjs example.
In this example i have simple remove all space from and i will perform to get remove all space in string It is possible by replace method. Its help to replace string in reactjs.
Here i will give you simple example to remove all space from string " Wel come to Nice Snip pets!" into "WelcometoNiceSnippets" . It is very easy and simple, So you can understand easily.
Example
import React from 'react'
export default class Home extends React.Component{
render(){
var myStr = " Wel come to Nice Snip pets"; // space at both end
var newStr = myStr.replace(/\s/g, "");
return(
<div>
<p><strong>String : </strong>{myStr}</p>
<p><strong>Remove All Space : </strong>{result}</p>
</div>
);
}
}
It will help you...
#React.js