“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
If you only want to check for the presence, instead of also retrieving the value, you can use a regular expression in combination with String.matches. Check out the Javadoc page of java.util.regex.Pattern for more information. Don't forget to let your regex end with ".*", because String.matches looks for a match of the entire String.