JSFiddle - React, Tailwind, and code Playground

JavaScript

var input = 'This is a test string - | - |.  - | - ';

alert(input.replace(/- \|/g, '|'));