I have a string which contains key value pairs like "this:1 is:2 a:3 Bigtest:4 and:5 i:6 want:7 to:8 pass:9 in:10 this:11 test:12 and:13 string:14 continues:15"

Now I want to extract the value of a tag (say test) from this string. I am not able to extract the value of the tag test which is 12 because the matching logic which I have written matches the tab Bigtest and gives output as 4.

I am new in C# so need some expert help on this one.

My logic: message is the string containing key values and attribute is name of tag (test)

```
public static string GetAttributeValueByName(string message, string attributeName)
{
    int startIndex = message.IndexOf(attributeName + ":");

    string attribute = message.Substring(startIndex + (attributeName + "=").Length);

int position = attribute.IndexOf(' ', 1);

   if (position != -1)
{
    string attributeValue = attribute.Substring(1, position - 1);
    return attributeValue;
}

return "";
}

```

Thanks in advance.