syntax of contains method in java
Could any one please tell me the syntax of contains method for pattern matching in strings
in java?
Web Development
Could any one please tell me the syntax of contains method for pattern matching in strings
in java?
by geert pante
Hi
Usually, I use the indexOf method and see if it returns -1 or not.
String a="string";
int i = a.indexOf("substring");
if(i==-1){
//a does not contain substring
}
else{
//i is first pos from which substring starts
}
In JDK 1.4 there is java.util.regexp for more advanced pattern matching. The Jakarta ORO package has some interesting stuff, also.
greetings, Geert.
by sankar_2209
by sankar_2209
This discussion is closed to new replies.
Sort by Trending