I have a large list which is populated with different types of feed urls for cameras, the URL structure is slightly different each time.
I need to strip out or replace the Segments/fields from the different URL types and create valid ones, I am not sure if this is even possible with regular expressions
Examples of URLS:
rtsp://IPADDRESS/
http://IPADDRESS/videostream.asf
http://IPADDRESS//iphone/11?[USERNAME]:[PASSWORD]&
http://IPADDRESS/img/video.mjpeg
Segments which always exist: IPADDRESS
Segments which are always the same (if they exist) IPADDRESS [USERNAME] [PASSSWORD]
The end results is I need to separate each segment into variables so I can use them to create a valid URL.
For example I will use this URL "http://IPADDRESS//iphone/11?[USERNAME]:[PASSWORD]" and replace the segments with valid data
EDIT:
The URLS are stored in a database, its not coming from the URL field in a browser.
I am attempting it using multiple str_replaces, but I am not sure how reliable this is, it might be better with a loop. But how would you break the url up using a loop:
$string = str_replace('IPADDRESS', '10.10.10.10', $string);
$string = str_replace('[USERNAME]', 'user1', $string);
http://10.10.10.10//iphone/11?user1:mypass
Thanks for your help
parse_url()?