.contains seems to return true for most things, even if one or two chars match. Is there a way to make it more restrictive?

I assume you're talking about String.contains(), please be specific there are lots of contains methods :)

If you want to match a string more restrictively to patterns, i would suggest looking at regular expressions, which allow you to create a definition of a pattern, for example

"abc"

which will only return true if these characters appear. You can be much more specific and do a lot more with regular expressions though.

Have a look at these sites.
Hope this helps!

http://download.oracle.com/javase/1.4.2/docs/api/java/util/regex/Pattern.html
http://en.wikipedia.org/wiki/Regular_expression
http://regexpal.com/ (allows you to write and test regexp)

Regex.
Edit: Sorry, cross-posted. ^^ What he said.

Thanks! I'll look into regex!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.