---
schema_version: "1"
id: 8dcacc9561fa0af70281f7bce6decfe2fa8544888327b6e520ed5d4accdc7b88
title: Wildcards
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/intro_wildcards.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/intro_wildcards.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: ce5650ee7b6d8cd0e0ab26d64c9e408553c7c074dd7853c51fdca42657ca1acc
description: Use wildcard characters to match text patterns in Connect REST API and Connect in Apex searches.
---
# Wildcards

Use wildcard characters to match text patterns in Connect REST API and Connect 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 Connect REST API request:

/chatter/feed-elements?q=chat\*

This example is a Connect in Apex method call:

ConnectApi.ChatterFeeds.searchFeedElements(null, 'chat\*');

You can specify the following wildcard characters to match text patterns in your search:

<table class="featureTable sort_table" summary="">


        <thead class="thead sorted" align="left">
          <tr>
            <th class="featureTableHeader  " id="d56315e52">Wildcard</th>

            <th class="featureTableHeader  " id="d56315e55">Description</th>

          </tr>

        </thead>

        <tbody class="tbody">
          <tr>
            <td class="entry" headers="d56315e52" data-title="Wildcard">*</td>

            <td class="entry" headers="d56315e55" data-title="Description">
              <p class="p">Asterisks match zero or more characters at the middle or end of your search term.
                For example, a search for <em class="ph i">john*</em> finds items that start with <em class="ph i">john</em>, such
                as, <em class="ph i">john</em>, <em class="ph i">johnson</em>, or <em class="ph i">johnny</em>. A search for <em class="ph i">mi* meyers</em>
                finds items with <em class="ph i">mike meyers</em> or <em class="ph i">michael meyers</em>.</p>

              <p class="p">If you are searching for a literal asterisk in a word or phrase, then escape the
                asterisk (precede it with the <samp class="codeph soql">\</samp> character).</p>

            </td>

          </tr>

          <tr>
            <td class="entry" headers="d56315e52" data-title="Wildcard">?</td>

            <td class="entry" headers="d56315e55" data-title="Description">Question marks match only one character in the middle or end of your search term.
              For example, a search for <em class="ph i">jo?n</em> finds items with the term <em class="ph i">john</em> or
              <em class="ph i">joan</em> but not <em class="ph i">jon</em> or <em class="ph i">johan</em>. You can't use a ? in a lookup
              search.
            </td>

          </tr>

        </tbody>

      </table>

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.