.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


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://regexpal.com/ (allows you to write and test regexp)

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.