หากต้องการลบข้อความระหว่างสองส่วนของสตริง ให้ใช้ JavaScript regex
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อเรียนรู้วิธีลบข้อความระหว่างวงเล็บ -
<html>
<head>
<script>
var str = "Welcome to Qries (website)";
document.write(str);
// Removing text between parentheses
document.write("<br>"+str.replace(/ *\([^)]*\) */g, ""));
</script>
</head>
<body>
</body>
</html> ผลลัพธ์
