Regex: absolute url to relative url (C#)

Posted by splatto on Stack Overflow See other posts from Stack Overflow or by splatto
Published on 2010-03-18T17:18:32Z Indexed on 2010/03/18 17:21 UTC
Read the original article Hit count: 290

Filed under:
|
|
|

I need a regex to run against strings like the one below that will convert absolute paths to relative paths under certain conditions.

<p>This website is <strong>really great</strong> and people love it <img alt="" src="http://localhost:1379/Content/js/fckeditor/editor/images/smiley/msn/teeth_smile.gif" /></p>

Rules: - If the url contains "/Content/" I would like to get the relative path - If the url does not contain "/Content/", it is an external file, and the absolute path should remain

Regex unfortunatley is not my forte, and this is too advanced for me at this point. If anyone can offer some tips I'd appreciate it.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about regex

Related posts about c#