I am getting System.IndexOutOfRangeException everytime I try to compile my program. This is where the error is happening.

public static string findlinks2(string source) 
        {
            
                char quotes = (char)34; //sets the char variable to quotes since you can't use it in a string normally
                string searchstring = (quotes + "fmt_url_map" + quotes + ":" + quotes); //sets the searchstring to "fmt_url_map":
                string[] fmt1 = System.Text.RegularExpressions.Regex.Split(source, searchstring); //splits html into 2 arrays
                
                string fmt2 = fmt1[1].ToString();

The error is occuring when is trys to assign the variable fmt2 the contents of fmt[1].ToString();. The error is obviously because the array fmt[1] does not exist but I dont know why???

Recommended Answers

All 2 Replies

It doesn't exist because it is not finding your search string.

It doesn't exist because it is not finding your search string.

Thanks I just realised I was searching for the wrong string. Big help!!! Is there any sort of systemj where I can give you a thumbs up on DANIWEB? I only joined last week

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.