Varg's colleague had an awfully difficult problem challenge to solve: remove the language parameter ("lang") from a query string.

Well, difficult for Varg's colleague. Though most of us would apply some substring finesse, this particular developer hammered away with a brute force approach.

Dim MyPage As String = Request.Url.ToString
MyPage = Replace(MyPage, "&lang=en", "")
MyPage = Replace(MyPage, "&lang=gr", "")
MyPage = Replace(MyPage, "&lang=EN", "")
MyPage = Replace(MyPage, "&lang=GR", "")
MyPage = Replace(MyPage, "&lang=En", "")
MyPage = Replace(MyPage, "&lang=Gr", "")
MyPage = Replace(MyPage, "&lang=eN", "")
MyPage = Replace(MyPage, "&lang=gR", "")
MyPage = Replace(MyPage, "&LANG=EN", "")
MyPage = Replace(MyPage, "&LANG=GR", "")

MyPage = Replace(MyPage, "?lang=en", "")
MyPage = Replace(MyPage, "?lang=gr", "")
MyPage = Replace(MyPage, "?lang=EN", "")
MyPage = Replace(MyPage, "?lang=GR", "")
MyPage = Replace(MyPage, "?lang=En", "")
MyPage = Replace(MyPage, "?lang=Gr", "")
MyPage = Replace(MyPage, "?lang=eN", "")
MyPage = Replace(MyPage, "?lang=gR", "")
MyPage = Replace(MyPage, "?LANG=EN", "")
MyPage = Replace(MyPage, "?LANG=GR", "")

Upon seeing this solution, Varg replied to his coworker, "this doesn't seem to cover the '?LaNg=en' and '&lANg=gr' scenarios." I'll let you guess how the code was updated to include those.

[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!