<?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 can I manually change badly formatted data using a search with regex to replace all \&amp;quot; with just a single quote &amp;quot; ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142267#M39452</link>
    <description>&lt;P&gt;@somesoni2 I'd think you could covert this to answer ?&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jul 2015 20:40:35 GMT</pubDate>
    <dc:creator>aljohnson_splun</dc:creator>
    <dc:date>2015-07-23T20:40:35Z</dc:date>
    <item>
      <title>How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142262#M39447</link>
      <description>&lt;P&gt;I have messed up log data for a specific type of event, and I wanted to fix it manually. Basically, when the data was entered, it was entered with a &lt;CODE&gt;\"&lt;/CODE&gt; in the program, with the slash for escaping to insert a &lt;CODE&gt;"&lt;/CODE&gt; character in a string, instead of just simply a &lt;CODE&gt;"&lt;/CODE&gt;. I wanted to go through all the old records and simply replace the &lt;CODE&gt;\"&lt;/CODE&gt; with a &lt;CODE&gt;"&lt;/CODE&gt;. How would I go about doing this? It seems like I'd use some variation of regex and the replace command, but I can't figure out how to do that. Thanks!&lt;/P&gt;

&lt;P&gt;Picture included to further demonstrate what I mean. &lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/505i811A9DEAA0362CA3/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Thanks for help in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 18:31:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142262#M39447</guid>
      <dc:creator>faramarz</dc:creator>
      <dc:date>2015-07-23T18:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142263#M39448</link>
      <description>&lt;P&gt;How does this data come into splunk (script, etc)?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 19:15:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142263#M39448</guid>
      <dc:creator>bmacias84</dc:creator>
      <dc:date>2015-07-23T19:15:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142264#M39449</link>
      <description>&lt;P&gt;it's a log file fed in by another server and script. I could change the script, but it wouldn't affect the past events already in the system. Looking to cleanse it and make the data more accessible, you know what I mean?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 19:17:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142264#M39449</guid>
      <dc:creator>faramarz</dc:creator>
      <dc:date>2015-07-23T19:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142265#M39450</link>
      <description>&lt;P&gt;You can't update the indexed data but you can update the raw data at search time. Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search |  rex mode=sed "s/(\\\\\")/\"/g" | ...rest of the search
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Update&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I think this should work.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event | search event="Out of Stock" | rex mode=sed "s/(\\\\\")/\"/g" | spath event |...rest of the search
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Basically, first remove the junk characters and then do the spath to get the field extraction.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 19:21:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142265#M39450</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2015-07-23T19:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142266#M39451</link>
      <description>&lt;P&gt;I still can't search the individual fields. I'd like to make them searchable at the least, if not correct the error. Is there a way to do that? I tried: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event| spath event | search event="Out of Stock" | rex mode=sed "s/(\\\\\")/\"/g" | rename body.recordtype AS recordtype, body.action AS action, body.apikey AS apikey, body.id AS id, body.displayname AS displayname, body.upc AS upc, body.sku AS sku, body.manufacturer AS manufacturer, body.description AS description, body.color AS color, body.size AS size, body.baseprice AS baseprice, body.averagecost AS averagecost, body.category AS category, body.taxable AS taxable, body.ishazmatitem AS ishazmatitem, body.inventory AS inventory | eval x=mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(mvzip(recordtype, action, ","), apikey, ","), id, ","), displayname, ","), upc, ","), sku, ","), manufacturer, ","), description, ","), color, ","), size, ","), baseprice, ","),  averagecost, ","),  category, ","), taxable, ","),  ishazmatitem, ","),  inventory, ",")| mvexpand x | eval x = split(x,",") | eval recordtype=mvindex(x,0) | eval action=mvindex(x,1) | eval apikey=mvindex(x,2) | eval id=mvindex(x,3) | eval displayname=mvindex(x,4) | eval upc=mvindex(x,5) | eval sku=mvindex(x,6) | eval manufacturer=mvindex(x,7) | eval description=mvindex(x,8) | eval color=mvindex(x,9) | eval size=mvindex(x,10) | eval baseprice=mvindex(x,11) | eval averagecost=mvindex(x,12) | eval category=mvindex(x,13) | eval taxable=mvindex(x,14) | eval ishazmatitem=mvindex(x,15) | eval inventory=mvindex(x,16) | table recordtype, action, apikey, id, displayname, upc, sku, manufacturer, description, color, size, baseprice, averagecost, category, taxable, ishazmatitem, inventory
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The issue is body.recordtype and the rest of body.* doesn't work to search it. Does anyone know how to make it searchable?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 20:13:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142266#M39451</guid>
      <dc:creator>faramarz</dc:creator>
      <dc:date>2015-07-23T20:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142267#M39452</link>
      <description>&lt;P&gt;@somesoni2 I'd think you could covert this to answer ?&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 20:40:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142267#M39452</guid>
      <dc:creator>aljohnson_splun</dc:creator>
      <dc:date>2015-07-23T20:40:35Z</dc:date>
    </item>
    <item>
      <title>Re: How can I manually change badly formatted data using a search with regex to replace all \" with just a single quote " ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142268#M39453</link>
      <description>&lt;P&gt;I was looking for something like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;event | spath event | search event="Out of Stock" | rex mode=sed "s/(\\\\\")/\"/g" | rex field=body "\"recordtype\":(?[^,]+)," | eval body.recordtype = recordtype 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which is repeatable for each field&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jul 2015 20:46:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-manually-change-badly-formatted-data-using-a-search/m-p/142268#M39453</guid>
      <dc:creator>faramarz</dc:creator>
      <dc:date>2015-07-23T20:46:07Z</dc:date>
    </item>
  </channel>
</rss>

