JSFiddle - React, Tailwind, and code Playground
HTML
<!-- I am passing a string of `country code` into `new RegExp` and wanted to replace with the blank space if there is country code available in mobile number.
-->
<script>
window.onload = callme();
function callme()
{
var mobileNum = "2341234567890";
var countryCode = "234";
var re = new RegExp(/^234+/i);
//var re = new RegExp('\\{'+countryCode+'\\}','gi');
//var re = new RegExp("ReGeX" + countryCode + "ReGeX");
var againNew = mobileNum.replace(re, '');
alert(againNew);
}
</script>