Тема: Creating a regex to get multiple values and print

I'm looking for any help with the code below. Basically the ip:port string keeps changing and may contain more than one true value in str and i wonder if is possible to use a regex using the search function to get the all ip:port and print in demo.

<p id="demo"></p>

<script>
var str = "Please 127.0.0.1:80 locate where 127.0.0.2:80 occurs!";
var pos = str.search("\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?):\d{1,5}\b");
document.getElementById("demo").innerHTML = pos;
</script>

Thanks

2

Re: Creating a regex to get multiple values and print

String.prototype.matchAll().

Regex with 'g' modificator