Due to shield encryption, I have to get rid of any SOQL queries filtered with encrypted fields. Thought is to remove the filter from soql and validate the retrieved soql results against the searchKey using a string method. I am able to get replacements for = (->equals) and IN (->contains) operators but did not find any for LIKE operator. Could anyone please help me with any other way? Is this the efficient way of doing?

Select Id from Account where Name LIKE: searchKey 

where searchKey is a string with wildcards

Please ignore any syntax errors


That would be a Pattern:

Pattern p = Pattern.compile('h.+o world');
String s = 'hello world';
if(p.matcher(s).matches()) {
  // Matched!

You'll need to learn about Regular Expressions, which are far more powerful than wildcards.

  • This works! Thanks a lot for sharing! – Kanikala May 21 at 14:28
  • @Kanikala You're welcome! – sfdcfox May 21 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.