Use wildcard characters to match text patterns in Chatter REST API and Chatter in Apex searches.
A common use for wildcards is searching a feed. Pass a search string
and wildcards in the
q parameter.
This example is a
Chatter REST API request:
/chatter/feed-elements?q=chat*
This example is a
Chatter in Apex method call:
ConnectApi.ChatterFeeds.searchFeedElements(null, 'chat*');
You can specify the following wildcard characters to match text
patterns in your search:
* |
Asterisks match zero or more characters at the middle or end of your
search term. For example, a search for john* finds items that start with john,
such as, john, johnson, or johnny. A search for mi* meyers finds
items with mike meyers or michael meyers.
If
you are searching for a literal asterisk in a word or phrase, then escape the
asterisk (precede it with the \
character). |
? |
Question marks match only one character in the middle or end of
your search term. For example, a search for jo?n finds items with the term
john or joan but not jon or johan. You can't use a ? in a
lookup search.
|
When using wildcards, consider the following notes:
- The more focused your wildcard search, the faster the search results are returned, and
the more likely the results will reflect your intention. For example, to search for all
occurrences of the word prospect (or prospects, the plural form), it is more efficient to
specify prospect* in the search string than to
specify a less restrictive wildcard search (such as prosp*) that could return extraneous matches (such as prosperity).
- Tailor your searches to find all variations of a word. For example, to find property and properties, you would specify propert*.
- Punctuation is indexed. To find * or ? inside a phrase, you must enclose your search string in
quotation marks and you must escape the special character. For example, "where are you\?" finds the phrase where are you?. The escape character (\) is required in order for this search to work
correctly.