<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Matching several strings in a field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567396#M197726</link>
    <description>&lt;P&gt;This worked.&amp;nbsp; I just had to remove the quotes around the strings since I was not looking for them.&lt;/P&gt;&lt;P&gt;regex FIELD1="(ABC\(Z) | (DEF\(Z) | (GHIJK\(Z) | (LMNOP\(Z)"&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Sep 2021 10:19:29 GMT</pubDate>
    <dc:creator>gelspas</dc:creator>
    <dc:date>2021-09-17T10:19:29Z</dc:date>
    <item>
      <title>Matching several strings in a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567261#M197673</link>
      <description>&lt;P&gt;I have a field (FIELD1) that may contain one of several strings.&amp;nbsp; These strings may appear in different locations within FIELD1.&amp;nbsp; I would like to select all records where FIELD1 contains any of these strings.&lt;/P&gt;&lt;P&gt;Example of 4 strings:&amp;nbsp; &amp;nbsp;"ABC(Z"&amp;nbsp; &amp;nbsp;"DEF(Z"&amp;nbsp; &amp;nbsp;"GHIJK (Z" "LMNOP (Z"&lt;/P&gt;&lt;P&gt;What is an efficient method for selecting any records that contain any one of these strings in any location within FIELD1?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 14:12:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567261#M197673</guid>
      <dc:creator>gelspas</dc:creator>
      <dc:date>2021-09-16T14:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Matching several strings in a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567263#M197674</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/205635"&gt;@gelspas&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you have a limited number of strings, you could use a regex like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=FIELD1 "(?&amp;lt;your_string&amp;gt;(\"ABC\(Z\")|(\"DEF\(Z\")|(\"GHIJK \(Z\")|(\"LMNOP \(Z\"))"&lt;/LI-CODE&gt;&lt;P&gt;putting much attention when you write the strings to search.&lt;/P&gt;&lt;P&gt;In this way, when one of the strings is present, you have that string in the field your_string. otherwise the field is empty.&lt;/P&gt;&lt;P&gt;If instead you have many strings, you could put them in a lookup, called e.g. "patterns.csv", with one field called "pattern" and run a search like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=your-index [ | inputlookup patterns.csv | rename pattern AS query | fields query ]
| ...&lt;/LI-CODE&gt;&lt;P&gt;in this way you use the strings in the lookup to filter your events.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 14:21:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567263#M197674</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-16T14:21:18Z</dc:date>
    </item>
    <item>
      <title>Re: Matching several strings in a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567279#M197681</link>
      <description>&lt;P&gt;Thank you but I do not think this rex accomplishes what I need or perhaps I am reading it wrong?&amp;nbsp; My regex knowledge is not strong.&lt;/P&gt;&lt;P&gt;I only wish to keep records where FIELD1 contains one of the 4 strings.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the example below only the first two records should be kept because they match on ABC(Z and GHIJK(Z.&amp;nbsp; The third record would not match.&lt;/P&gt;&lt;P&gt;Examples of&amp;nbsp; FIELD1:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Record 1: 09162021 CMDONE ABC(Z123456) MORE TEXT&lt;/P&gt;&lt;P&gt;Record 2: 09152021 CMD TWO GHIJK(ZABC123) MORE TEXT&lt;/P&gt;&lt;P&gt;Record 3: 09162021 CMD3 LMNO(A1234BD) MORE TEXT&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 15:38:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567279#M197681</guid>
      <dc:creator>gelspas</dc:creator>
      <dc:date>2021-09-16T15:38:27Z</dc:date>
    </item>
    <item>
      <title>Re: Matching several strings in a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567353#M197705</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/205635"&gt;@gelspas&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you're not interested to know which string is found, you could use the regex command to search those strings:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| regex FIELD1="(\"ABC\(Z\")|(\"DEF\(Z\")|(\"GHIJK \(Z\")|(\"LMNOP \(Z\")"&lt;/LI-CODE&gt;&lt;P&gt;My hint is to use the lookup solution so you'll have a dynamic solution instead to have the strings to search in the code.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 06:46:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567353#M197705</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-09-17T06:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: Matching several strings in a field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567396#M197726</link>
      <description>&lt;P&gt;This worked.&amp;nbsp; I just had to remove the quotes around the strings since I was not looking for them.&lt;/P&gt;&lt;P&gt;regex FIELD1="(ABC\(Z) | (DEF\(Z) | (GHIJK\(Z) | (LMNOP\(Z)"&lt;/P&gt;&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 10:19:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Matching-several-strings-in-a-field/m-p/567396#M197726</guid>
      <dc:creator>gelspas</dc:creator>
      <dc:date>2021-09-17T10:19:29Z</dc:date>
    </item>
  </channel>
</rss>

