In my old database there are fields of such content:
a:2:{s:6:"item-0";a:1:{s:17:"siteurl";s:25:"https://www.urlsite.com/";}s:6:"item-1";a:1:{s:17:"siteurl";s:29:"https://urlsite2.org/";};a:1:{s:17:"siteurl";s:29:"https://urlsite3.com/";}}
I need to select only the url from this, so that something like this happens:
https://www.urlsite.com/,https://urlsite2.org/,https://urlsite3.com/
At the moment I use this construction:
.*?(http.*?(\.org|\.com))
However, I get this result:
https://www.urlsite.com,https://urlsite2.org,https://urlsite3.com,/";}}
It is not possible to select the end of the line after the last url and it gets into the result.
,/";}}
>Solution :
A JavaScript implementation:
const text =
'a:2:{s:6:"item-0";a:1:{s:17:"siteurl";s:25:"https://www.urlsite.com/";}s:6:"item-1";a:1:{s:17:"siteurl";s:29:"https://urlsite2.org/";};a:1:{s:17:"siteurl";s:29:"https://urlsite3.com/";}}';
const result = text.match(/http.*?(.com|.org)\//gm);
console.log(result.join(','));
Results in:
https://www.urlsite.com/,https://urlsite2.org/,https://urlsite3.com/