I have a string that is formatted as follows:
"key1=value1;key2=value2;key3=value3"
for any number of key / value pairs.
I need to check that a certain key exists (let it be called "specialkey"). If so, I want a value associated with it. If there are many "special keys", I want only the first.
Now I am looking for the index "specialkey". I take the substring starting at this index, then look at the index of the first character = . Then I look for the index of the first character ; . The substring between the two indices gives me the value associated with the "special key".
This is not an elegant solution, and it really bothers me. What an elegant way to find a value that matches "specialkey"?
source share