Skip to content
Advertisement

How to match or replace a pattern of two appearances of one statement in RegEx? [closed]

I have a text like bellow:

Ryan, Ryan needs to find his papers.

I want to change the pattern of

JavaScript

to

JavaScript

So, it doesn’t necessarily need to be Ryan, it could be any other name. And the output should look like this:

JavaScript

So, basically this code but a variable instead of Ryan.

JavaScript

Advertisement

Answer

Use

JavaScript

See regex proof and PHP proof.

Explanation

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement