c# parsing a string to 2 seprate string values

mion shion 241 Reputation points

Good evening all,

i have been trying to get this to work for a while now,

so example of the text.

Found YouTube URL for "Faceless 1-7 - Download My Conscious" : https://www.youtube.com/watch?v=1d2ovu4IMdE

i want just the stuff insde the "" and the youtube url

i have tryied.

        public void splitstrings(string path)  
                if(path.Contains("Found YouTube URL for"))  
                var content = path;  
                var parts = content.Split(':'); // split on spaces  
                var string1 = parts.First();  
                var string3 = parts.Last();  
                var theRest = content;  
                string1.Replace("Found YouTube URL for \"\" ","");  

so what i want as a result is,

string 1 to be Artist's name ( the text inside the quotes ) and,
string 2 to be the youtube url,

but cant seem to get the desired result as it wont remove anything just give me a print out of it unedited

thank you in advance.

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
9,467 questions
0 comments No comments
{count} votes

Accepted answer
  1. WayneAKing 4,521 Reputation points

    How to proceed depends very much on how consistent is the
    data format. Assuming all lines have the same format as
    the example, then maybe this example will give you some

    static void Main(string[] args)  
         string path =  
             @"Found YouTube URL for ""Faceless 1 - 7 - Download My Conscious"" : " +  
         int x = path.IndexOf("\"");  
         int y = path.IndexOf("\"", x+1);  
         string title= path.Substring(x+1, y - x - 1);  
         int urlstrt = path.IndexOf("http");  
         string url = path.Substring(urlstrt);  
    Faceless 1 - 7 - Download My Conscious  
    • Wayne
    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful