title: Regex filtering of messages in SNS
body: <p>Is there a way to filter messages based on <strong>Regex</strong> or substring in AWS <em>SNS</em>?</p>
  
  <p><a href="https://docs.aws.amazon.com/sns/latest/dg/message-filtering.html" rel="noreferrer">AWS Documentation for filtering messages</a> mentions three types of filtering for strings:</p>
  
  <ul>
  <li>Exact matching (whitelisting)</li>
  <li>Anything-but matching (blacklisting)</li>
  <li>Prefix matching</li>
  </ul>
  
  <p>I want to filter out messages based on substrings in the messages, for example</p>
  
  <p>I have a S3 event that sends a message to SNS when a new object is added to S3, the contents of the message are as below:</p>
  
  <pre><code>{
      "Records": [
          {
              "s3": {
                  "bucket": {
                      "name": "images-bucket"
                  },
                  "object": {
                      "key": "some-key/more-key/filteringText/additionaldata.png"
                  }
              }
          }
      ]
  }
  </code></pre>
  
  <p>I want to keep the messages if only <strong>filteringText</strong> is present in <em>key</em> field. </p>
  
  <p><strong>Note</strong>: The entire message is sent as text by S3 notification service, so Records is not a json object but string.</p>