<?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: Help with Regex in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567896#M10045</link>
    <description>&lt;P&gt;Just the replace i was looking for. Thanks Much!!&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Sep 2021 19:18:01 GMT</pubDate>
    <dc:creator>ak9092</dc:creator>
    <dc:date>2021-09-21T19:18:01Z</dc:date>
    <item>
      <title>Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567287#M9992</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I want to remove all the back slashes and double quotes from following fields -&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;conn=\"pass\""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ip=\"10.23.22.1\""&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I am trying to extract with &lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;EVAL-conn = replace(conn,"\\\\(.),"") and&amp;nbsp;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;STRONG&gt;EVAL-ip= replace(ip,"\\\\(.),"")&amp;nbsp;&lt;/STRONG&gt; in my props.conf but it is not removing the last double quotes&amp;nbsp;and give me following results -&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;conn=pass"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ip=10.23.22.1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Results I want :&amp;nbsp; conn=pass &amp;amp;&amp;nbsp;ip=10.23.22.1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Can someone please help/guide me with this extraction.&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 20:40:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567287#M9992</guid>
      <dc:creator>ak9092</dc:creator>
      <dc:date>2021-09-20T20:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567321#M9995</link>
      <description>&lt;P&gt;Are those your literal evals? Because they seem to be syntactically bad.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;EVAL-conn = replace(conn,"\\\\","") 
EVAL-ip= replace(ip,"\\\\","")&lt;/LI-CODE&gt;&lt;P&gt;That looks more correct.&lt;/P&gt;&lt;P&gt;I don't quite follow what you want to do with the loc though.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Sep 2021 20:30:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567321#M9995</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-16T20:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567376#M10000</link>
      <description>&lt;P&gt;&lt;A href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884" target="_blank"&gt;@PickleRick&lt;/A&gt;&amp;nbsp;thank you for your response.&lt;/P&gt;&lt;P&gt;The EVAL statements shared by you and the one which I have shared above both are working fine only if the field is like conn="\success\" , but not working if there is an additional double quotes at the end like&amp;nbsp;&lt;SPAN&gt;conn=\"pass\"".&amp;nbsp; So in both; the results looks like -&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Conn=&lt;/SPAN&gt;&lt;SPAN&gt;pass", what I want is; conn=pass&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 08:26:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567376#M10000</guid>
      <dc:creator>ak9092</dc:creator>
      <dc:date>2021-09-17T08:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567419#M10002</link>
      <description>&lt;P&gt;OK. But the evals only remove backslashes. So you end up with&lt;BR /&gt;conn="pass""&lt;/P&gt;&lt;P&gt;I suppose (I don't know your sourcetype and the rest of props/transforms) that it's getting interpreted as key-value and the quotes are not getting removed by any evals but are dropped as part of K/V parsing. You'd need another eval to drop the quotes.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 13:42:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567419#M10002</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-17T13:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567733#M10026</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp; The eval which I am using removes the double quotes too, but its just not removing the additional quotes which is coming in some events.&lt;/P&gt;&lt;P&gt;In below run anywhere search for conn2 field you will see one double quote remaining at the end, which I don't want.&lt;/P&gt;&lt;P&gt;|makeresults&lt;/P&gt;&lt;P&gt;|eval conn="\\\"08/24/2021\\\"\""&lt;/P&gt;&lt;P&gt;|eval conn2=replace(conn,"\\\\(.)","")&lt;/P&gt;&lt;P&gt;Also there is no such any specific extraction in my props.conf and it roughly looks something like below&lt;/P&gt;&lt;P&gt;[mysourcetype]&lt;/P&gt;&lt;P&gt;EVAL-conn = replace(conn,"\\\\(.),"")&lt;/P&gt;&lt;P&gt;With following regex, I am able to replace all the backslashes and double quotes the way I want but I am unable to make it work with Splunk replace command.&lt;/P&gt;&lt;P&gt;&lt;A href="https://regex101.com/r/glIfKz/1" target="_blank"&gt;https://regex101.com/r/glIfKz/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;&amp;nbsp; ,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 18:09:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567733#M10026</guid>
      <dc:creator>ak9092</dc:creator>
      <dc:date>2021-09-20T18:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567735#M10027</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/209974"&gt;@ak9092&lt;/a&gt;&amp;nbsp;Use the below query in your search:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| regex field=conn "\\"(?P&amp;lt;conn&amp;gt;\w+)"
| regex field=ip "\\"(?P&amp;lt;conn&amp;gt;\d+.\d+.\d+.\d+)"&lt;/LI-CODE&gt;&lt;P&gt;Also, If this reply helps you, an upvote would be appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 18:37:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567735#M10027</guid>
      <dc:creator>ashvinpandey</dc:creator>
      <dc:date>2021-09-20T18:37:44Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567742#M10029</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/199978"&gt;@ashvinpandey&lt;/a&gt;&amp;nbsp;, thank you for your response.&lt;/P&gt;&lt;P&gt;I am trying to achieve this using props.conf.&lt;/P&gt;&lt;P&gt;Also the data in "conn" field can be a mix of IP , string and other special characters just like the "loc" field which you can see in the question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567742#M10029</guid>
      <dc:creator>ak9092</dc:creator>
      <dc:date>2021-09-20T19:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567745#M10031</link>
      <description>&lt;P&gt;Well... splunk sometimes guesses stuff. Sometimes too much.&lt;/P&gt;&lt;P&gt;Let me show you. I push an event to a HEC input on my home splunk server. The data is as follows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{"event":"&amp;lt;13&amp;gt;1 2021-09-20T21:22:30.495495+02:00 test=\"test\"","host":"test1","index":"test1","sourcetype":"syslog"}&lt;/LI-CODE&gt;&lt;P&gt;It gets ingested into the index&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;13&amp;gt;1 2021-09-20T21:21:30.495495+02:00 test="test"&lt;/LI-CODE&gt;&lt;P&gt;When I look into the event I see that the "test" field is being parsed out because it's a key-value pair so Splunk automaticaly recognizes it.&lt;/P&gt;&lt;P&gt;To make things even more interesting, in case of plain syslog sourcetype it gets the value from between the quotes even if you have additional unbalanced quote at the end (as in your example). So I suppose your K/V pairs might also be being parsed automaticaly.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 19:36:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567745#M10031</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-20T19:36:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567749#M10033</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Yes , there are some events in which it is extracting exactly the way you mentioned.&lt;/P&gt;&lt;P&gt;But then there are some event which are coming as a K/V pairs inside another field,&lt;/P&gt;&lt;P&gt;So the extraction which I am doing is for the field, where i am getting data like -&lt;/P&gt;&lt;P&gt;field1="field2=\"some_string_value\", field3=\"some_path_value\", field4=\"again_some_value\", ... fieldN=\"valueN\""&lt;/P&gt;&lt;P&gt;So now from field1 to field4 everything is getting formatted perfectly fine using&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;EVAL-field = replace(field,"\\\\(.),"")&lt;/P&gt;&lt;P&gt;The issue comes in "fieldN" where an extra double quotes is added to close the quotes which is opened at field1.&lt;/P&gt;&lt;P&gt;Now the problem is my fieldN can be any any field and can contain multiple back slashes , double quotes and any string, so need some robust solution here which will work fine on any kind of field value.&lt;/P&gt;&lt;P&gt;If somehow I can make the below regex work with replace command , then i guess it should solve my problem, but unfortunately its giving me error with something like -&amp;nbsp;&lt;SPAN&gt;"|ev...{snipped} {errorcontext = ce(conn1,[\\"]+],"")}'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://regex101.com/r/glIfKz/1" target="_blank" rel="nofollow noopener noreferrer"&gt;https://regex101.com/r/glIfKz/1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;|makeresults | eval conn1="\\\"08/24/2021\\\"\"" |eval conn=replace(conn1,[\\"]+],"")&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 20:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567749#M10033</guid>
      <dc:creator>ak9092</dc:creator>
      <dc:date>2021-09-20T20:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567759#M10035</link>
      <description>&lt;P&gt;You are creating a calculated field right through props.conf, so rather than use replace why not use left and right trim and trim off backslash and quotes from the ends, e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;ip=ltrim(rtrim(ip,"\\\""),"\\\"")&lt;/LI-CODE&gt;&lt;P&gt;which trims off the backslash \\ and quotes \" from both ends of the string.&lt;/P&gt;&lt;P&gt;You can also use replace like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;conn=replace(conn,"[\\\\\"]","")&lt;/LI-CODE&gt;&lt;P&gt;which will replace all backslash and quotes in the entire string, regardless of where they are.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 22:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567759#M10035</guid>
      <dc:creator>bowesmana</dc:creator>
      <dc:date>2021-09-20T22:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Help with Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567896#M10045</link>
      <description>&lt;P&gt;Just the replace i was looking for. Thanks Much!!&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/6367"&gt;@bowesmana&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Sep 2021 19:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/Help-with-Regex/m-p/567896#M10045</guid>
      <dc:creator>ak9092</dc:creator>
      <dc:date>2021-09-21T19:18:01Z</dc:date>
    </item>
  </channel>
</rss>

