CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2008
    Posts
    154

    [RESOLVED] Questions on parse operations

    Not sure if they are called operations but here is the deal. I wrote some code.. it works perfectly - now some of the code I hijacks from coding forums. here is the code..

    Code:
                string[] files = Directory.GetFiles(GameRef.GetDocumentsDirectory + @"\My Documents\My Games\RPGBXL");
                string dir = GameRef.GetDocumentsDirectory + @"\My Documents\My Games\RPGBXL";
    
                foreach (string file in files)
                {
                    FileInfo f = new FileInfo(file);
                    if (f.Extension == ".xml")
                    {
                        //parses out that huge Directory address!
                        string filename = Regex.Match(file, @"[^\\]*$").Value;
                        FilesToLoad.Add(filename); 
                    }
                }
    this line here

    Code:
    string filename = Regex.Match(file, @"[^\\]*$").Value;
    I don't know how it works... it works perfectly! And I know it parsing that huge directory string to make it smaller but what do these things mean?:

    ^ , \\ , *$ - I have no idea what those are doing

  2. #2
    Join Date
    Aug 2010
    Posts
    5

    Re: Questions on parse operations

    regular expressions are what they are. They are a highly tuned way of parsing and finding data. Here is a helpful link: http://www.regular-expressions.info/reference.html

    Have fun with it!

  3. #3
    Join Date
    Jun 2008
    Posts
    154

    Re: Questions on parse operations

    Awesome THANKS!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured