<?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 use regex to reformat a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402004#M116332</link>
    <description>&lt;P&gt;Hi @ronbuzon, &lt;/P&gt;

&lt;P&gt;sorry for the late reply. &lt;/P&gt;

&lt;P&gt;Let me fix that solution:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=Message "Attributes:\s*(?&amp;lt;Attributes&amp;gt;.+)"&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Aug 2018 19:09:02 GMT</pubDate>
    <dc:creator>horsefez</dc:creator>
    <dc:date>2018-08-23T19:09:02Z</dc:date>
    <item>
      <title>How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401993#M116321</link>
      <description>&lt;P&gt;Need assistance regex to reformat the field&lt;/P&gt;

&lt;P&gt;the field is Message. And the output is &lt;/P&gt;

&lt;P&gt;"&lt;EM&gt;Reason: Details: Attributes: folderPathname folder ManagerDisplayName david foster OwnerEmail user@useremail"&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;when developing the regex to select anything after "Attributes:" i was able to create this rex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)Attributes: (?.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works in regex101.com and displays this field &lt;/P&gt;

&lt;P&gt;the SPLUNK query that I wrote is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(base search)||rex field=Message "Attributes: (?.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But the message field still shows the entire message value. &lt;/P&gt;

&lt;P&gt;Any assistance will help&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401993#M116321</guid>
      <dc:creator>ronbuzon</dc:creator>
      <dc:date>2018-08-14T15:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401994#M116322</link>
      <description>&lt;P&gt;are you trying this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   ... |rex field=Message "Attributes: (?&amp;lt;Message&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:32:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401994#M116322</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-08-14T15:32:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401995#M116323</link>
      <description>&lt;P&gt;Got this error-&lt;BR /&gt;
Error in 'rex' command: Encountered the following error while compiling the regex 'Attributes: (?.+)': Regex: unrecognized character after (? or (?-&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:35:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401995#M116323</guid>
      <dc:creator>ronbuzon</dc:creator>
      <dc:date>2018-08-14T15:35:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401996#M116324</link>
      <description>&lt;P&gt;updated the query ...special characters was missed&lt;/P&gt;</description>
      <pubDate>Tue, 14 Aug 2018 15:37:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401996#M116324</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2018-08-14T15:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401997#M116325</link>
      <description>&lt;P&gt;regex101 reports a pattern error on:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)Attributes: (?.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you wanted to capture the part after attributes then it would be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)Attributes: (?P&amp;lt;fieldname&amp;gt;.+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you wanted to regex match then it would be | rexgex :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?i)Attributes: (.+)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Aug 2018 23:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401997#M116325</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2018-08-14T23:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401998#M116326</link>
      <description>&lt;P&gt;Gjanders, &lt;/P&gt;

&lt;P&gt;Thank you for the recommendation and the feedback. &lt;/P&gt;

&lt;P&gt;I used the regex command you have provided. however, the field from the search results still provide the entire value of the field. It seems like the rex command does not work. &lt;/P&gt;

&lt;P&gt;(base search)||rex field=Message " (?i)Attributes: (?P.+)"&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 18:36:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401998#M116326</guid>
      <dc:creator>ronbuzon</dc:creator>
      <dc:date>2018-08-15T18:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401999#M116327</link>
      <description>&lt;P&gt;Hi there, are you trying to trim values of &lt;CODE&gt;Message&lt;/CODE&gt; field after indexing and create a new field &lt;CODE&gt;new_field&lt;/CODE&gt; with these trimmed values? Or are you trying to trim the values of &lt;CODE&gt;Message&lt;/CODE&gt; field before indexing?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Aug 2018 19:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/401999#M116327</guid>
      <dc:creator>sudosplunk</dc:creator>
      <dc:date>2018-08-15T19:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402000#M116328</link>
      <description>&lt;P&gt;If your goal was to create a new field then:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (base search)|rex field=Message " (?i)Attributes: (?P&amp;lt;new_field&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could potentially override the Message field at search time, where I'm assuming message is a valid field name:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (base search)|rex field=Message " (?i)Attributes: (?P&amp;lt;Message&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you wanted to do this at index time it's completely different, or if your trying to extract the field with the name message from the event itself:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (base search)|rex " (?i)Attributes: (?P&amp;lt;Message&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Aug 2018 21:59:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402000#M116328</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2018-08-15T21:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402001#M116329</link>
      <description>&lt;P&gt;Hi @ronbuzon,&lt;/P&gt;

&lt;P&gt;if you are trying to extract the following data out of the given string, then try something like this.&lt;/P&gt;

&lt;P&gt;Your sample data:&lt;BR /&gt;
    Reason: Details: Attributes: folderPathname folder ManagerDisplayName david foster OwnerEmail user@useremail&lt;/P&gt;

&lt;P&gt;What you want to extract:&lt;BR /&gt;
    folderPathname folder ManagerDisplayName david foster OwnerEmail user@useremail&lt;/P&gt;

&lt;P&gt;How you can do that:&lt;BR /&gt;
    | rex field=Message "Attributes:\s*(?&lt;ATTRIBUTES&gt;.+)"&lt;/ATTRIBUTES&gt;&lt;/P&gt;

&lt;P&gt;Please give me feedback, if that solves your problem.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 14:33:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402001#M116329</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-08-21T14:33:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402002#M116330</link>
      <description>&lt;P&gt;Hi @pyro_wood&lt;BR /&gt;
thanks for responding and giving your input. &lt;/P&gt;

&lt;P&gt;i tried your solution and got this error:&lt;/P&gt;

&lt;P&gt;Error in 'rex' command: Encountered the following error while compiling the regex 'Attributes:\s*(?.+)': Regex: unrecognized character after (? or (?-&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 14:46:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402002#M116330</guid>
      <dc:creator>ronbuzon</dc:creator>
      <dc:date>2018-08-21T14:46:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402003#M116331</link>
      <description>&lt;P&gt;@ronbuzon , I think @493669 has already given you updated query... you need to provide a name for the capturing group, which is your case is &lt;CODE&gt;Message&lt;/CODE&gt;. You should try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourExistingSearch&amp;gt;
| rex field=Message "Attributes: (?&amp;lt;Message&amp;gt;.+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test the same on regex101 as well &lt;A href="https://regex101.com/r/SZzS59/1"&gt;https://regex101.com/r/SZzS59/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2018 15:25:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402003#M116331</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-08-21T15:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use regex to reformat a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402004#M116332</link>
      <description>&lt;P&gt;Hi @ronbuzon, &lt;/P&gt;

&lt;P&gt;sorry for the late reply. &lt;/P&gt;

&lt;P&gt;Let me fix that solution:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;| rex field=Message "Attributes:\s*(?&amp;lt;Attributes&amp;gt;.+)"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Aug 2018 19:09:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-regex-to-reformat-a-field/m-p/402004#M116332</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2018-08-23T19:09:02Z</dc:date>
    </item>
  </channel>
</rss>

