0

Whats the best way to remove a query string (the question mark variables) from a image url.

Say I got a good image such as http://i.ebayimg.com/00/s/MTYwMFgxNjAw/z/zoMAAOSwMpZUniWv/$_12.JPG?set_id=880000500F But I can't really save it properly without adding a bunch of useless checking code because of the query string crap after it.

I just need http://i.ebayimg.com/00/s/MTYwMFgxNjAw/z/zoMAAOSwMpZUniWv/$_12.JPG

Looking for the proper regular expression that handles this so I could replace it with blank.

SSpoke
  • 5,656
  • 10
  • 72
  • 124

1 Answers1

2

It might be simple enough not to worry about regex.

This would work:

Dim cleaned = url.Substring(0, url.IndexOf("?"c))
Enigmativity
  • 113,464
  • 11
  • 89
  • 172
  • Thanks still need to wrap it with indexof conditional if-statement to check if ? even exists or it will error. That's why I perfer regex's but ya this seems better thanks I hear this is faster then regex too. (I judge from this http://stackoverflow.com/questions/2540969/remove-querystring-from-url ) – SSpoke May 27 '15 at 04:11