<?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: How to remove a comma from a field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278832#M84218</link>
    <description>&lt;P&gt;Thanks Jeremiah,&lt;/P&gt;

&lt;P&gt;That works to extract the correct value into the field, but that damn comma still screws up the rest of the field values by throwing them off when they are extracted...for example, the File_Size field returns the User value and the Device_ID field returns the Domain value for affected records...&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 08:43:45 GMT</pubDate>
    <dc:creator>silasbarnesva</dc:creator>
    <dc:date>2020-09-29T08:43:45Z</dc:date>
    <item>
      <title>How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278827#M84213</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;We have a field in Splunk that is populated with filenames (e.g.)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;G:/some_directory/somefile.txt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Everything works just fine unless users put a comma in as part of the filename:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;G:/some_directory/somefile,somemore.txt
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to remove any commas in the field in question? I've tried the following with no luck:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=somesource | rex mode=sed field=filename "s/,//" | table filename
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;thx!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 01:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278827#M84213</guid>
      <dc:creator>silasbarnesva</dc:creator>
      <dc:date>2016-02-11T01:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278828#M84214</link>
      <description>&lt;P&gt;Try any of following method line2 or line 3(the first line is just to generate some sample events, replace it with your base search)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| gentimes start=-1 | eval filename="G:/some_directory/somefile,somemore.txt" | table filename 
| eval filename1=replace(filename,",","") 
| rex field=filename mode=sed "s/,//"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 01:57:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278828#M84214</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-02-11T01:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278829#M84215</link>
      <description>&lt;P&gt;No dice I'm afraid.&lt;/P&gt;

&lt;P&gt;As stated in the question, I've already tried your Line 3 version to no avail. Just tried Line 2 but it doesn't remove those commas which results in other fields being polluted by false data from the field bleeds. Thanks for trying though &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 02:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278829#M84215</guid>
      <dc:creator>silasbarnesva</dc:creator>
      <dc:date>2016-02-11T02:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278830#M84216</link>
      <description>&lt;P&gt;I think the problem here is that the offending comma doesn't actually populate in the extracted field so it's not able to be rex'd out - it's interpretered as a field separator.&lt;/P&gt;

&lt;P&gt;To give a full example of a log entry:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2016-02-11 10:01:00,Minor,PC-Name,Continue, - Caller MD5=105202dad5dd174300xxxxxxxxxxxxxx,File Delete,Begin: 2016-02-11 10:01:00,End: 2016-02-11 10:02:00,Rule: Log files written to USB drives | [AC5-1.1] Log writing to USB drives,7100,C:/Program Files (x86)/Microsoft Office/Office14/EXCEL.EXE,0,No Module Name,D:/some_directory/somefile,somemore.xls,User: MrRobot,Domain: EvilCorp,Action Type: ,File size (bytes): 500000,Device ID: USBSTOR\Disk&amp;amp;Ven_Verbatim&amp;amp;Prod_&amp;amp;Rev_8.00\19120xxxxxxxxx&amp;amp;0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So we know that between &lt;STRONG&gt;Name,&lt;/STRONG&gt; and &lt;STRONG&gt;,User&lt;/STRONG&gt;, it shouldn't matter how many commas appear - everything between those two identifiers should = filename. &lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 03:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278830#M84216</guid>
      <dc:creator>silasbarnesva</dc:creator>
      <dc:date>2016-02-11T03:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278831#M84217</link>
      <description>&lt;P&gt;So the actual problem is that the field is truncated?  In your example, the filename field would contain&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;D:/some_directory/somefile
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But you want it to contain&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;D:/some_directory/somefile,somemore.xls
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Could you just hack the field like this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "Name,(?&amp;lt;filename&amp;gt;.*),User:"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Feb 2016 03:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278831#M84217</guid>
      <dc:creator>Jeremiah</dc:creator>
      <dc:date>2016-02-11T03:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278832#M84218</link>
      <description>&lt;P&gt;Thanks Jeremiah,&lt;/P&gt;

&lt;P&gt;That works to extract the correct value into the field, but that damn comma still screws up the rest of the field values by throwing them off when they are extracted...for example, the File_Size field returns the User value and the Device_ID field returns the Domain value for affected records...&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 08:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278832#M84218</guid>
      <dc:creator>silasbarnesva</dc:creator>
      <dc:date>2020-09-29T08:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove a comma from a field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278833#M84219</link>
      <description>&lt;P&gt;Ahh ok.  Can you put up your props/transforms for this sourcetype?  Let's see how the extraction is configured.  Thats where I think you'll need to make changes.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Feb 2016 04:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-remove-a-comma-from-a-field-value/m-p/278833#M84219</guid>
      <dc:creator>Jeremiah</dc:creator>
      <dc:date>2016-02-11T04:18:46Z</dc:date>
    </item>
  </channel>
</rss>

