JSFiddle - React, Tailwind, and code Playground

JavaScript

var a = "this is | first and | second";

alert( a.replace( "|", "_" ) );
alert( a.replace( /\|/g, "_" ) );