0

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

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by asif49
2

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)

1

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

Edited by Ezzaral: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.