Hum, I
roughly modified this regex to capture the whole url with prefix:
- adding a capturing set ot round brackets at the start and at the end
- making the sub-sets of round brackets non-capturing by adding "?:" at their start
- escaping the /-slashes as they would be interpreted as a metachar, so you can use the g parameter to capture multiple urls on one line
To:
/(https?:
\/
\/(
?:[-\w\.]+)+(
?::\d+)?(
?:\/(
?:[\w/_\.]*(
?:\?\S+)?)?)?
)/galias regtest {
var %text = http://www.mirc.com/mirc.html sometext https://forums.mirc.com/ubbthreads.php sometext www.mirc.com
if $regex(%text,/(https?:\/\/(?:[-\w\.]+)+(?::\d+)?(?:\/(?:[\w/_\.]*(?:\?\S+)?)?)?)/g) {
echo -a captured urls: $regml(0)
var %n = 1
while ($regml(%n)) {
echo -a %n : $v1
inc %n
}
}
}
captured urls: 2
1 :
http://www.mirc.com/mirc.html2 :
https://forums.mirc.com/ubbthreads.phpIt won't capture the last url, as this one doesn't include a http(s) prefix - don't know what exactly you'd like to match.
Furthermore, I'm no regex pro. And this one really doesn't look neat. For sure someone else will be able to improve it a lot
