function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aathmacharan SelvasudarsananAathmacharan Selvasudarsanan 

Getting This ERROR: -- Invalid identifier '​​​​​​​​'. Apex identifiers must start with an ASCII letter (a-z or A-Z) followed by any number of ASCII letters (a-z or A-Z), digits (0 - 9), '$', '_'.

public class customSearchSobjectLWC {​
    @AuraEnabled
    public static List<Books__c> getBookById(string searchKey){​​​​​​​​
    string searchKeyword = '%' + searchKey + '%';
    list<Books__c> books = new list<Books__c>();
    
    for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
    From Books__c WHERE Name LIKE : searchKeyword]){​​​​​​​​
    books.add(obj);
    }​​​​​​​​
    return books;
}
 @AuraEnabled
    public static List<Books__c> getBookByauthor(string searchKey){​​​​​​​​
    string searchKeyword = '%' + searchKey + '%';
    list<Books__c> books = new list<Books__c>();
    
    for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
    From Books__c WHERE Author__c LIKE : searchKeyword]){​​​​​​​​
    books.add(obj);
    }​​​​​​​​
    return books;
    }​​​​​​​​
    
    @AuraEnabled
    public static List<Books__c> getBookBycategory(string searchKey){​​​​​​​​
    string searchKeyword = '%' + searchKey + '%';
    list<Books__c> books = new list<Books__c>();
    
    for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
    From Books__c WHERE Category__c LIKE : searchKeyword])
    {​​​​​​​​
    books.add(obj);
    }​​​​​​​​
    return books;
    }​​​​​​​​
    
}
Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

There were some extra characters in some lines. I have modified the code as below.  Please try using this
 
public class customSearchSobjectLWC {
    @AuraEnabled
    public static List<Books__c> getBookById(string searchKey){
    string searchKeyword = '%' + searchKey + '%';
    list<Books__c> books = new list<Books__c>();
    
    for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
    From Books__c WHERE Name LIKE : searchKeyword]){
    books.add(obj);
    }
    return books;
}
 @AuraEnabled
    public static List<Books__c> getBookByauthor(string searchKey){
    string searchKeyword = '%' + searchKey + '%';
    list<Books__c> books = new list<Books__c>();
    
    for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
    From Books__c WHERE Author__c LIKE : searchKeyword]){
    books.add(obj);
    }
    return books;
    }
    
    @AuraEnabled
    public static List<Books__c> getBookBycategory(string searchKey){
    string searchKeyword = '%' + searchKey + '%';
    list<Books__c> books = new list<Books__c>();
    
    for(Books__c obj :[Select Name,Return_Date__c,Book_Status__c,Author__c,Category__c
    From Books__c WHERE Category__c LIKE : searchKeyword])
    {
    books.add(obj);
    }
    return books;
    }
    
}
If this solution helps, Please mark it as best answer.

Thanks,