get image link from string

image , string Ireland
  • 12 years ago
    Hi, I am looking how to search a string for the first instance of text 'img src=' Then select the text in the quotes after it. This then leaves me with the link to the image. For example... img src="http://website/str_strip/000000000/00000000/0000000/30223.print.gif" Thanks for any help...
  • 12 years ago
    //Capture the image url however you like string myImageUrl = "img src=\"http://website/str_strip/000000000/00000000/0000000/30223.print.gif\""; //Create a delimiter string, convert to char[] to pass to String.Split() string delimiterString = "\""; char[] delimiter = delimiterString.ToCharArray(); //Call String.Split() and pass the delimiter string[] results = myImageUrl.Split(delimiter); Console.WriteLine(results[1]); // Writes http://website/str_strip/000000000/00000000/0000000/30223.print.gif This is one way to do it, and just the first one I thought of. You may have to change the delimiter based on how your URL looks. Hope this helps!
  • 12 years ago
    Well it looks like it destroyed my formatting. Sorry, I'm not used to this forum yet. //Capture the image url however you like string myImageUrl = "img src=\"http://website/str_strip/000000000/00000000/0000000/30223.print.gif\""; //Create a delimiter string, convert to char[] to pass to String.Split() string delimiterString = "\""; char[] delimiter = delimiterString.ToCharArray(); //Call String.Split() and pass the delimiter string[] results = myImageUrl.Split(delimiter); Console.WriteLine(results[1]); // Writes http://website/str_strip/000000000/00000000/0000000/30223.print.gif
  • 12 years ago
    LOL, I give up. :)

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The greatest performance improvement of all is when a system goes from not-working to working.” - John Ousterhout