views:

31

answers:

1

Hello guys,

I've searched but was unable to find an existing regex function. Has anybody done this before?

I wish to add a port number, or remove a potantially existing one from a url in php. To use in some functions which translate a given url to the secure one, unsecure one, etc.

Now I need a second SSL secured site on the server so I need to dynamically add a port number while converting http to https, and remove any port number while converting from https to http.

Thanks, Duck

+3  A: 

Instead of a regex, you can use the built-in parse_url function to break apart and reassemble the URL to match your requirements.

Charles
Thanks charles, it was the first thing I considered.parse_url had some problems in the past, so I wanted to use regex, this could also work faster. After reading your reply I checked it again, looks like parse_url is fixed. I think I can use this.Thanks,Duck
SuperDuck