Skip to content

All topics  /  React

Reactjs String Replace Example

React ·

Reactjs String Replace Example

Hello friends,

In this blog, i will show you how to replace string in reactjs. We will talk about string replace example in reactjs. i would like to share with you how to string replace in reactjs.

In this example i have simple string replace and i will perform to get replace string It is possible by replace method. Its help to replace string in reactjs.

Here i will give you simple example to replace string "Hi Dev!" into "Hi Guys!" . 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 = "Hi Dev!";
        var newStr = myStr.replace("Dev", "Guys");
        return(
            <div>
                <h1>String Replace Example</h1>
                <p><strong>Old String : </strong>{myStr}</p>
                <p><strong>New String : </strong>{newStr}</p>
            </div>
        );
    }
}

It will help you...