I need to use regex to search a string and fix certain urls. I need to remove the beginning / from links like this one:
/admin.somedomain.com or /somedomain.com
There are a lot of other absolute urls so I can't just strip out any leading / characters. Any help would be greatly appreciated.
This is dealing with user entered text usually html from TinyMCE but sometimes from plain text boxes with and without other HTML (or I would handle it differently and deal with the links directly instead of having to search a string for them first). Unfortunately sometimes the urls are entered incorrectly for a href or img src etc.
I do want links like "/image.jpg" "/webapp/getfile?id=3354"
but not links like "/somedomain.com" "/admin.somedomain.com"
Here is an example of text I might need to clean up
<p><a href="/webapp/GetFile?id={2C59BC2D}"><img src="/wahelper/GetImage?id=308" alt="" width="100" height="100" /></a></p> <p><a href="/admin.somedomain.com">test</a></p>
:and taking the first block and seeing if theres more than one/where if there is, leave it alone, then where there isn't remove the first char if that char is a/:then I would see what the beginning chars are see if it has a//in it or a/