<?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: Search And Global Replace Like Function in Splunk ??? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98543#M25363</link>
    <description>&lt;P&gt;I have following entries in Log file&lt;/P&gt;

&lt;P&gt;&lt;CONTRACTID&gt;true&lt;/CONTRACTID&gt;&lt;NAME name-type="Name"&gt;true&lt;/NAME&gt;&lt;INCURREDDATE&gt;true&lt;/INCURREDDATE&gt; &lt;/P&gt;

&lt;P&gt;&lt;CONTRACTID&gt;true&lt;/CONTRACTID&gt;&lt;NAME name-type="Name"&gt;true&lt;/NAME&gt;&lt;DATE&gt;true&lt;/DATE&gt;&lt;BR /&gt;
I would like to search and extract only the tag names .&lt;BR /&gt;
For example output should be tag names comma separated&lt;/P&gt;

&lt;P&gt;ContractId, Name, IncurredDate&lt;BR /&gt;
ContractId, Name, Date&lt;/P&gt;

&lt;P&gt;My search command replaces only first occurence of &lt;CONTRACTID&gt; so i tried something like rex mode=sed "s/find/replace/g" but even that didnt help&lt;BR /&gt;
Please let me know the rex command to extract tag names&lt;/CONTRACTID&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2010 04:32:44 GMT</pubDate>
    <dc:creator>bansi</dc:creator>
    <dc:date>2010-12-03T04:32:44Z</dc:date>
    <item>
      <title>Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98540#M25360</link>
      <description>&lt;P&gt;I have XML log file in following format&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;ContractId&amp;gt;true&amp;lt;/ContractId&amp;gt;&amp;lt;Name name-type="Name"&amp;gt;true&amp;lt;/Name&amp;gt;&amp;lt;IncurredDate&amp;gt;true&amp;lt;/IncurredDate&amp;gt; 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to search and replace the abov xml entry in the log file to 
ContractId, Name, IncurredDate&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 02:52:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98540#M25360</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-03T02:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98541#M25361</link>
      <description>&lt;P&gt;I am not sure what you mean. Can you post an example output you're looking for?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 04:04:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98541#M25361</guid>
      <dc:creator>ftk</dc:creator>
      <dc:date>2010-12-03T04:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98542#M25362</link>
      <description>&lt;P&gt;Are you just trying to extract fields?&lt;/P&gt;

&lt;P&gt;Have you found the &lt;A href="http://www.splunk.com/base/Documentation/4.1.6/SearchReference/Xmlkv" rel="nofollow"&gt;&lt;CODE&gt;xmlkv&lt;/CODE&gt;&lt;/A&gt; command?&lt;/P&gt;

&lt;P&gt;In general, the &lt;A href="http://www.splunk.com/base/Documentation/4.1.6/SearchReference/Eval" rel="nofollow"&gt;Search Reference&lt;/A&gt; and &lt;A href="http://www.splunk.com/base/Documentation/latest/SearchReference/SearchCheatsheet" rel="nofollow"&gt;Search Command Cheat Sheet&lt;/A&gt; are good places to start.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;Update:&lt;/P&gt;

&lt;P&gt;Substitution really doesn't seem to be the best approach here. Why not just extract the matches for the beginning of a tag into a new field, then join them back together if you want a single line?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=_raw max_match=50 "\&amp;lt;(?&amp;lt;keys&amp;gt;[A-Za-z]+)"
| eval keys=mvjoin(keys,",")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you're really that set on substitution for some reason, I suppose you could do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval keys=_raw
| rex field=keys mode=sed "s/&amp;lt;([A-Za-z]+).*?&amp;lt;\/\1&amp;gt;/\1,/g"
| eval keys=substr(keys,1,len(keys)-1)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These are shown pulling from &lt;CODE&gt;_raw&lt;/CODE&gt;, which is the full event text - if the XML string is already in another field you'll need to adjust for that.&lt;/P&gt;

&lt;P&gt;While working with &lt;CODE&gt;rex&lt;/CODE&gt;, if you need a reference on regular expression syntax, you might want to check&lt;BR /&gt; &lt;A href="http://www.regular-expressions.info/" rel="nofollow"&gt;http://www.regular-expressions.info/&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 04:29:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98542#M25362</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-12-03T04:29:09Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98543#M25363</link>
      <description>&lt;P&gt;I have following entries in Log file&lt;/P&gt;

&lt;P&gt;&lt;CONTRACTID&gt;true&lt;/CONTRACTID&gt;&lt;NAME name-type="Name"&gt;true&lt;/NAME&gt;&lt;INCURREDDATE&gt;true&lt;/INCURREDDATE&gt; &lt;/P&gt;

&lt;P&gt;&lt;CONTRACTID&gt;true&lt;/CONTRACTID&gt;&lt;NAME name-type="Name"&gt;true&lt;/NAME&gt;&lt;DATE&gt;true&lt;/DATE&gt;&lt;BR /&gt;
I would like to search and extract only the tag names .&lt;BR /&gt;
For example output should be tag names comma separated&lt;/P&gt;

&lt;P&gt;ContractId, Name, IncurredDate&lt;BR /&gt;
ContractId, Name, Date&lt;/P&gt;

&lt;P&gt;My search command replaces only first occurence of &lt;CONTRACTID&gt; so i tried something like rex mode=sed "s/find/replace/g" but even that didnt help&lt;BR /&gt;
Please let me know the rex command to extract tag names&lt;/CONTRACTID&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 04:32:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98543#M25363</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-03T04:32:44Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98544#M25364</link>
      <description>&lt;P&gt;the following sed command doesnt work&lt;BR /&gt;
rex mode=sed s/&lt;EM&gt;&amp;gt;true.&lt;/EM&gt;/&amp;gt;/,/g&lt;BR /&gt;
What am i missing?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 04:43:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98544#M25364</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-03T04:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98545#M25365</link>
      <description>&lt;P&gt;Yes i tried xmlkv and all other search commands in cheat sheet but nothing fits the bill. Look like i am running out of options.&lt;BR /&gt;
Each entry in the log file is XML so i have to extract xml node names without worrying about its content all i need is node names.&lt;BR /&gt;
The xml entry looks like this&lt;/P&gt;

&lt;P&gt;&lt;CONTRACTID&gt;true&lt;/CONTRACTID&gt;&lt;NAME name-type="Name"&gt;true&lt;/NAME&gt;&lt;INCURREDDATE&gt;true&lt;/INCURREDDATE&gt;&lt;/P&gt;

&lt;P&gt;All i need to extract is node names like ContractId, Name, IncurredDate.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 04:58:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98545#M25365</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-03T04:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98546#M25366</link>
      <description>&lt;P&gt;Ok. Trying to use substitution to blank out part of the string could work, but sounds like a more complicated approach than you need. Field extraction is likely to be easier. See edits above -- it's similar in principle to your other question at &lt;A href="http://answers.splunk.com/questions/9505/filter-search-results"&gt;http://answers.splunk.com/questions/9505/filter-search-results&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 05:19:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98546#M25366</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2010-12-03T05:19:50Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98547#M25367</link>
      <description>&lt;P&gt;Thanks it works&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2010 05:43:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98547#M25367</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-03T05:43:28Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98548#M25368</link>
      <description>&lt;P&gt;How would i do the same for values meaning how to extract just the values instead of keys and then comma separate those values&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2010 05:43:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98548#M25368</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-04T05:43:59Z</dc:date>
    </item>
    <item>
      <title>Re: Search And Global Replace Like Function in Splunk ???</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98549#M25369</link>
      <description>&lt;P&gt;How would i remove duplicate keys in eval keys=mvjoin(keys,",")&lt;/P&gt;</description>
      <pubDate>Wed, 22 Dec 2010 03:47:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-And-Global-Replace-Like-Function-in-Splunk/m-p/98549#M25369</guid>
      <dc:creator>bansi</dc:creator>
      <dc:date>2010-12-22T03:47:05Z</dc:date>
    </item>
  </channel>
</rss>

