<?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: Searching &amp;quot;%&amp;quot; with in a search string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225791#M66590</link>
    <description>&lt;P&gt;Thanks Rich!&lt;/P&gt;

&lt;P&gt;I have the following search now -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="prod" host="prod-as**" "*succeeded" "app=oraapp" | rex field=target "name=(?&amp;lt;MyFileName&amp;gt;[^,]*)" | search MyFileName=*%*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's not working. It is showing "No results found".&lt;/P&gt;

&lt;P&gt;I tried to see if the search is showing any result with "%" in it. I ran this query -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="prod" host="prod-as**" "*succeeded" "app=oraapp" | rex field=target "name=(?&amp;lt;MyFileName&amp;gt;[^,]*)" | stats count by name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Found the result -&lt;BR /&gt;
1213 Iriquois Dr%2C PHOTO  1&lt;BR /&gt;&lt;BR /&gt;
15%25 &lt;/P&gt;

&lt;P&gt;But when I try to look at the stats using "MyFileName", its not returning any result. It is showing "No results found".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="prod" host="prod-as**" "*succeeded" "app=oraapp" | rex field=target "name=(?&amp;lt;MyFileName&amp;gt;[^,]*)" | stats count by MyFileName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does this mean that MyFileName is not being populated?&lt;/P&gt;</description>
    <pubDate>Fri, 30 Sep 2016 17:34:44 GMT</pubDate>
    <dc:creator>runiyal</dc:creator>
    <dc:date>2016-09-30T17:34:44Z</dc:date>
    <item>
      <title>Searching "%" with in a search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225789#M66588</link>
      <description>&lt;P&gt;My logfile contains a rows like -&lt;/P&gt;

&lt;P&gt;...........&amp;amp;pic=pic%231.pdf&amp;amp;description=.......&lt;BR /&gt;
...........&amp;amp;pic=pic.pdf&amp;amp;description=.......&lt;BR /&gt;
...........&amp;amp;pic=pic%232.pdf&amp;amp;description=.......&lt;/P&gt;

&lt;P&gt;I need to get result if this string "&amp;amp;pic=&lt;EM&gt;.pdf" as "&lt;/EM&gt;&lt;EM&gt;%&lt;/EM&gt;*" in between it.&lt;/P&gt;

&lt;P&gt;So, in the result I shoul only get &lt;/P&gt;

&lt;P&gt;...........&amp;amp;pic=pic*&lt;EM&gt;%&lt;/EM&gt;&lt;EM&gt;231.pdf&amp;amp;description=.......&lt;BR /&gt;
...........&amp;amp;pic=pic&lt;/EM&gt;&lt;EM&gt;%&lt;/EM&gt;*232.pdf&amp;amp;description=.......&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:14:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225789#M66588</guid>
      <dc:creator>runiyal</dc:creator>
      <dc:date>2020-09-29T11:14:41Z</dc:date>
    </item>
    <item>
      <title>Re: Searching "%" with in a search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225790#M66589</link>
      <description>&lt;P&gt;I played around with this a bit, it's a tiny bit more finicky than I would have liked.  I think the problem is that the &lt;CODE&gt;%&lt;/CODE&gt; character is a breaker character, so it makes odd things happen inside Splunk.  The following may be a reliable way to work with it by creating a new field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... my search | rex field=target "πc=(?&amp;lt;MyFileName&amp;gt;[^&amp;amp;]*)" | search MyFileName=pic%*.pdf
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, your &lt;CODE&gt;my search&lt;/CODE&gt; is just whatever it takes to pull up all the events ("index=* sourcetype=something" or whatever).  The middle is the rex, and it creates a new field &lt;CODE&gt;MyFileName&lt;/CODE&gt; from the characters found after &lt;CODE&gt;πc=&lt;/CODE&gt; up to the first ampersand.  Once you have the field, it seems to reliably work for searching.  &lt;/P&gt;

&lt;P&gt;The above does just what you asked - finds the pdfs with the percent sign.  You could also use &lt;CODE&gt;| search MyFileName=pic%*&lt;/CODE&gt; which would pull out all files starting with pic and a percent sign.   &lt;/P&gt;

&lt;P&gt;So again, once you have that rex in place, after it you can ...&lt;BR /&gt;
To find all files  starting with the letters pic% : &lt;CODE&gt;| search MyFileName=pic%*&lt;/CODE&gt;&lt;BR /&gt;
To find all pdfs starting with the letters pic% and ending in pdf : &lt;CODE&gt;| search MyFileName=pic%*.pdf&lt;/CODE&gt;&lt;BR /&gt;
To find all pdfs that do NOT have a pic% at the front : &lt;CODE&gt;| search MyFileName!=pic%*.pdf&lt;/CODE&gt;&lt;BR /&gt;
Similarly, to find all &lt;EM&gt;anythings&lt;/EM&gt; in that field that have a percent sign: &lt;CODE&gt;| search MyFileName=*%*&lt;/CODE&gt;&lt;BR /&gt;
Lastly, to find all &lt;EM&gt;anythings&lt;/EM&gt; that don't have a percent sign: &lt;CODE&gt;| search MyFileName!=*%*&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2016 23:53:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225790#M66589</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-09-29T23:53:59Z</dc:date>
    </item>
    <item>
      <title>Re: Searching "%" with in a search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225791#M66590</link>
      <description>&lt;P&gt;Thanks Rich!&lt;/P&gt;

&lt;P&gt;I have the following search now -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="prod" host="prod-as**" "*succeeded" "app=oraapp" | rex field=target "name=(?&amp;lt;MyFileName&amp;gt;[^,]*)" | search MyFileName=*%*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But it's not working. It is showing "No results found".&lt;/P&gt;

&lt;P&gt;I tried to see if the search is showing any result with "%" in it. I ran this query -&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="prod" host="prod-as**" "*succeeded" "app=oraapp" | rex field=target "name=(?&amp;lt;MyFileName&amp;gt;[^,]*)" | stats count by name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Found the result -&lt;BR /&gt;
1213 Iriquois Dr%2C PHOTO  1&lt;BR /&gt;&lt;BR /&gt;
15%25 &lt;/P&gt;

&lt;P&gt;But when I try to look at the stats using "MyFileName", its not returning any result. It is showing "No results found".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="prod" host="prod-as**" "*succeeded" "app=oraapp" | rex field=target "name=(?&amp;lt;MyFileName&amp;gt;[^,]*)" | stats count by MyFileName
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Does this mean that MyFileName is not being populated?&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 17:34:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225791#M66590</guid>
      <dc:creator>runiyal</dc:creator>
      <dc:date>2016-09-30T17:34:44Z</dc:date>
    </item>
    <item>
      <title>Re: Searching "%" with in a search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225792#M66591</link>
      <description>&lt;P&gt;Can you provide a couple more of the raw events, preferably the whole or at least most of the event?  Might just be a little detail was overlooked and with that I can retest in a while.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 30 Sep 2016 18:49:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225792#M66591</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-09-30T18:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Searching "%" with in a search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225793#M66592</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index="prod" host="prod-as**" "*succeeded" "app=oraapp" | regex _raw=".*%.*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 30 Sep 2016 19:03:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225793#M66592</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-30T19:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Searching "%" with in a search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225794#M66593</link>
      <description>&lt;P&gt;Yes, so it looks like you are using a rex that looks for a string "name=" followed by characters that aren't commas.  &lt;CODE&gt;"name=(?&amp;lt;MyFileName&amp;gt;[^,]*)"&lt;/CODE&gt; So if given an event like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;age=23,name=billy,height=tall
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It would pull a field MyFileName of "billy".  I know the example ended up silly, but that's OK.  &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;But your initial pasting of events shows they look like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;age=23&amp;amp;name=billy&amp;amp;height=tall
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So you need to make sure you are looking for the string "name=" then characters up to but not including an ampersand.  Like &lt;CODE&gt;"name=(?&amp;lt;MyFileName&amp;gt;[^&amp;amp;]*)"&lt;/CODE&gt; .&lt;/P&gt;

&lt;P&gt;Unless the initial pastes were of the wrong data or got funged up during pasting.  So in either way, if you have further problems if you could paste in new event samples that would be great.  Of course, we'll just hope it all works!&lt;/P&gt;

&lt;P&gt;BTW, I &lt;A href="https://regex101.com/r/gGMvhD/1"&gt;put this stuff up into regex101.com&lt;/A&gt; so you can see how it determined what was matching, and this is off the original data way up in the question.&lt;/P&gt;</description>
      <pubDate>Sat, 01 Oct 2016 14:37:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Searching-quot-quot-with-in-a-search-string/m-p/225794#M66593</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-10-01T14:37:56Z</dc:date>
    </item>
  </channel>
</rss>

