You need to sign in to do that
Don't have an account?
Rockers
How to compare two strings
Hi,
I want to implement search functionality in my pages. where as, i have five fields.. In that,one field is Keywords:
Now, i want to compare the values of keywords with the values of object and i need to populate the matched data.
I split the string of keywords into into a array.
For this string comparison , while using like operator, the query returns null even though i gave exact matched data.
so, is there any way to compare the strings.
Regards,
Phanikumar
Can you post some code?
Did you try the compareTo or contains string methods? pg 256 of Apex developers guide.
Please post the code.
Why dont you try equals() method for comparision?
Hi,
I am using to checking the words exists or not. Not Exactly, comparing the words. Because, i am implementing search functionality here. So, we need to check the string is available or not. So, iam using like operator.
Now, i am working on it.
Hi
Try using "contains" and "compareTo" String methods
Examples of them:
String myString1 = 'abcde';
String myString2 = 'abcd';
Boolean result = myString1.contains(myString2);
System.assertEquals(result, true);
String myString1 = 'abcde';
String myString2 = 'abcd';
Integer result = myString1.compareTo(myString2);
System.assertEquals(result, 1);