To remove duplicate from string values use below formula
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function() { $("#btn1").click(function() { var result = "Samsung|Galaxy;Apple|iPhone7;Samsung|Note;Apple|iPhone7"; result = Array.from(new Set(result.split(';'))).toString(); $("#test1").text(result); }); }); </script> </head> <body> <p id="test1">This is a paragraph.</p> <button id="btn1">Check Duplicate Value </button> </body> </html>
INPUT STRING: Samsung|Galaxy;Apple|iPhone7;Samsung|Note;Apple|iPhone7
OUTPUT/ RESULT STRING: Samsung|Galaxy,Apple|iPhone7,Samsung|Note