I have the url inputs in various formats. I want to convert all into one standard format. Few example inputs are below.
- http://www.example.com
- https://in.example.com
- http://uk.example.com
- uk.example.com
From above all the inputs, I wish to convert into first one (http://www.example.com) with www. So I think we can replace the string if "www" not there.
$pattern = '/((http?|https)\:\/\/)?([a-zA-Z]+)\.example.com\/[a-z]{2}\/[a-zA-Z0-9]{5,30}/i';
I tried this pattern. I know it will match replace everything. SO please suggest me, how to do that.