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
RongzhongHuangRongzhongHuang 

SOSL - mismatched character ':' expecting '}'

Hi, if you search string contains ':', '-' within your SOSL statement, and use Search.query(), you would get exception like 'mismatched character' ...

I was wondering how many characters need to be escaped for SOSL statement. Is there a good way to handler these characters.

thanks, 
Sonam_SFDCSonam_SFDC
Hi,

The following characters are reserved: 
? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -

Reserved characters, if specified in a text search, must be escaped (preceded by the backslash \ character) in order to be properly interpreted. 
To handle them is to escape them using "\"

reference: http://www.salesforce.com/us/developer/docs/soql_sosl/index_Left.htm