-2

DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE; TextDocument activeDoc = dte.ActiveDocument.Object() as TextDocument;

        var text = activeDoc.CreateEditPoint(activeDoc.StartPoint).GetText(activeDoc.EndPoint);


        var input = (text);

        var regex = new Regex(@"(\bresourcekey\b+) = ");

        var match = regex.Matches(input);

        string matches = string.Empty;

        foreach(var item in match)
        {
            matches += item.ToString() + " "; 
        }

        MessageBox.Show(matches);

My regex command are fault(i know)but i want capture meta:resourcekey = "......" from my messagebox text i want only .... part of my capturing.

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86

2 Answers2

0

Here is plain regex

meta:resourcekey[\s]=[\s]\"(.*?)\"

And here is c# Example

var mydata = "meta:resourcekey = \"something\"";
Regex regex = new Regex("meta:resourcekey[\\s]*=[\\s]*\"(.*?)\\\"");
foreach (Match htmlPath in regex.Matches(mydata))
{
    Console.WriteLine(htmlPath.Groups[1].Value);
}
Mihir Dave
  • 3,954
  • 1
  • 12
  • 28
0
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE;
        TextDocument activeDoc = dte.ActiveDocument.Object() as TextDocument;

        var text = activeDoc.CreateEditPoint(activeDoc.StartPoint).GetText(activeDoc.EndPoint);


        var input = (text);

        Regex regex = new Regex(@"(meta:resourcekey)+(\W)+(\w*)+(\W)");

        var match = regex.Matches(input);

        string matches = string.Empty;

        foreach(var item in match)
        {
            matches += item.ToString() + " "; 
        }

        MessageBox.Show(matches);

I found the answer like that.That makes Scann the current page code and write to text and finally getting meta:resourcekey="something" all of the code pages... Write to MessageBox