To find multiple matches, write a JavaScript regular expression. You can try to run the following code to implement regular expression for multiple matches −
Example
<html> <head> <script> var url = 'https://www.example.com/new.html?ui=7&demo=one&demo=two&demo=three four', a = document.createElement('a'); a.href = url; var demoRegex = /(?:^|[&;])demo=([^&;]+)/g, matches, demo = []; while (matches = demoRegex.exec(a.search)) { demo.push(decodeURIComponent(matches[1])); } document.write(demo); </script> </head> <body> </body> </html>