11-02-2012 05:24 PM
Solved! Go to Solution.
11-02-2012 08:09 PM - edited 11-03-2012 07:47 AM
What are you trying to do - match to verify the String or match to provide some processing option?
11-03-2012 12:05 AM
11-03-2012 01:57 AM
This may helps you:
public boolean isEqualToString(String source, String pattern)
{
if (source == null || pattern==null)
return false;
if(source.length()==0||pattern.length()==0||source .length()<pattern.length())
return false;
int index=0;
while(index<source.length())
{
if(source.charAt(index)==pattern.charAt(0))
{
String str=source.substring(index,index+pattern.length()) ;
if(str.equals(pattern))//If you don't want case sensitive then use "str.equalsIgnoreCase(pattern)"
{
System.out.println("=========Equal String ==============: "+str);
return true;
}
}
index++;
}
return false;
}
//Example: boolean isContainsString=isEqualToString("Ali shaik ali", "ali");
Try this and let me know.
11-03-2012 03:40 AM
11-03-2012 05:41 AM - edited 11-03-2012 05:51 AM
lostdragon
First of all thanks for giving this type of suggesstion to find the solution in "less coding".
As you mentioned, we can get by using StringMatch class
//Example: boolean isMatch=hasString("Ali shaik ali", "ali");
public boolean hasString(String name, String pattern)
{
// new StringMatch(patternToMatch, caseSensitivity, spaceDelimitsNewPattern);
StringMatch match=new StringMatch(pattern,true,true);
if(match.indexOf(name)!=-1)
{
System.out.println("=======String: "+name+"=======has====== "+pattern+" : "+match.numStringsInPattern()+" times");
return true;
}
else
return false;
}
Try this and Let me know.
11-03-2012 06:43 AM