You should use regular expressions for this.
They are far more powerful than simple string matching, but you can use them for that purpose:
idx = regexp(s, 'parameter2$');
The $ matches at the end of the string.
You can also use regexp to split your string up into its parts:
tokens = regexp(s,'(.*)_(.*)_(.*)', 'tokens')
And then use straight string comparison on the third token.