locked
Find and Extract RRS feed

  • Question

  • User468878487 posted

    I need to parse a text looking for the string - [[Extract|xxxxxxx]] and extract the xxxxxxx characters.

    How would I do this?

    Friday, May 28, 2010 11:48 AM

Answers

  • User537870505 posted

    Many options available (including regular expressions). Here is one:

                string toFind = "[[Extract|";
                string toSearch = "Template[[Extract|ABCDE123456]]";
                int i = toSearch.IndexOf (toFind);
                if (i >= 0)
                {
                    int j = toSearch.IndexOf ("]", i + toFind.Length);
                    string temp = toSearch.Substring (i + toFind.Length, j - i - toFind.Length);
                    Console.WriteLine (temp);
                }
                else
                {
                    Console.WriteLine ("String not found");
                }


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 28, 2010 12:40 PM

All replies

  • User537870505 posted

    Many options available (including regular expressions). Here is one:

                string toFind = "[[Extract|";
                string toSearch = "Template[[Extract|ABCDE123456]]";
                int i = toSearch.IndexOf (toFind);
                if (i >= 0)
                {
                    int j = toSearch.IndexOf ("]", i + toFind.Length);
                    string temp = toSearch.Substring (i + toFind.Length, j - i - toFind.Length);
                    Console.WriteLine (temp);
                }
                else
                {
                    Console.WriteLine ("String not found");
                }


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 28, 2010 12:40 PM
  • User468878487 posted

    Thanks siva_sm

    Tuesday, June 1, 2010 5:11 AM