JSFiddle - React, Tailwind, and code Playground
by sundaramkumar
HTML
<!-- <textarea id="Lyricstuff" cols="60" rows="4">This is C# and this is C#m</textarea>
<button onclick="repl()">Replace</button>-->
<textarea id="Resultss" cols="60" rows="10"></textarea><br/>
<!--<input id="rs1" value="C#"/><input id="rt1" value="1"/> -->
JavaScript
var input = "ip ipaddress dhcp dhcpstring description networkcide network_cidr cidr ip cidrvalues";
//"description ip cidr";
//ip ipaddress dhcp dhcpstring cidr cidrvalues';
//var input ="ips";
var restrictedWords = ['ssh', 'ip', 'dhcp', 'cidr'];
for (var i = 0, len = restrictedWords.length; i < len; i++) {
var word = restrictedWords[i];
if (input.indexOf(word) != -1) {
word = word.replace(/[-\\()\[\]{}^$*+.?|]/g, '\\$&');
var regex = new RegExp('(\\s|^)(?:' + word + ')(?=\\s|$)', "g");
//document.getElementById('Resultss').value = document.getElementById('Resultss').value+'\n'+input.replace(regex, "$1" + word.toUpperCase());
input = input.replace(regex, "$1" + word.toUpperCase());
}
}
document.getElementById('Resultss').value = input;
//alert(input);