I have an sample string data
string state="This item (@"Item.Price", "item") is sold with an price (@"Item.Rate", "rate") per (@"Item.QTY", "Qty")";
I want the output as
string subStr="Item.Price|Item.Rate|Item.QTY"
Can someone please suggest some solution. I am trying to read this data from File. I have sample code like
if (!string.IsNullOrEmpty(state) && state != null)
{
while (state.IndexOf("Value(@\"") > 0)
{
int firstindex = state.IndexOf("(@\"");
int secondindex = state.IndexOf("\", \"");
if (firstindex > 0 && secondindex > 0)
{
keys.Add(state.Substring(firstindex + 3, secondindex - firstindex - 8));
state = state.Substring(secondindex + 3);
}
}
}
When data is large then this exception is thrown:
Length cannot be less than zero
Can somebody suggest some pattern matching mechanism for this.