<?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 write regex to extract fields with multiple values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165233#M46940</link>
    <description>&lt;P&gt;@MuS, not sure if renderXml option will impact the existing 50+ reports created using events in plain text format&lt;/P&gt;</description>
    <pubDate>Tue, 30 Dec 2014 05:08:27 GMT</pubDate>
    <dc:creator>basanthp</dc:creator>
    <dc:date>2014-12-30T05:08:27Z</dc:date>
    <item>
      <title>How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165229#M46936</link>
      <description>&lt;P&gt;The below is the windows security logs Message field data.&lt;BR /&gt;&lt;BR /&gt;
The Security_ID field is splunk identified and contains 2 values - Domain1\username1 and Domain2\username2.&lt;BR /&gt;&lt;BR /&gt;
I want to extract them in search query as 2 different fields using regex say myfield1=Domain1\username1 and myfield2=Domain2\username2.&lt;BR /&gt;&lt;BR /&gt;
Any pointers on how to write regex for this would be helpful?  &lt;/P&gt;

&lt;P&gt;I used the below query&lt;/P&gt;

&lt;P&gt;index="win_logs" sourcetype="WinEventLog:Security" (EventCode=4720)  | table Message&lt;/P&gt;

&lt;P&gt;"A user account was created.&lt;/P&gt;

&lt;P&gt;Subject:&lt;BR /&gt;
    Security ID:        Domain1\username1&lt;BR /&gt;
    Account Name:       username1&lt;BR /&gt;
    Account Domain:     Domain1&lt;BR /&gt;
    Logon ID:       0x1005dc243&lt;/P&gt;

&lt;P&gt;New Account:&lt;BR /&gt;
    Security ID:        Domain2\username2&lt;BR /&gt;
    Account Name:       username2&lt;BR /&gt;
    Account Domain:     Domain2&lt;/P&gt;

&lt;P&gt;Attributes:&lt;BR /&gt;
    SAM Account Name:   username2&lt;BR /&gt;
    Display Name:       first name, last name&lt;BR /&gt;
    User Principal Name:    -&lt;BR /&gt;
    Home Directory:     -&lt;BR /&gt;
    Home Drive:     -&lt;BR /&gt;
    Script Path:        -&lt;BR /&gt;
    Profile Path:       -&lt;BR /&gt;
    User Workstations:  -&lt;BR /&gt;
    Password Last Set:  &lt;NEVER&gt;&lt;BR /&gt;
    Account Expires:        &lt;NEVER&gt;&lt;BR /&gt;
    Primary Group ID:   513000000&lt;BR /&gt;
    Allowed To Delegate To: -&lt;BR /&gt;
    Old UAC Value:      0x0&lt;BR /&gt;
    New UAC Value:      0x15&lt;BR /&gt;
    User Account Control:&lt;BR /&gt;&lt;BR /&gt;
        Account Disabled&lt;BR /&gt;
        'Password Not Required' - Enabled&lt;BR /&gt;
        'Normal Account' - Enabled&lt;BR /&gt;
    User Parameters:    -&lt;BR /&gt;
    SID History:        -&lt;BR /&gt;
    Logon Hours:        &lt;VALUE not="" set=""&gt;&lt;/VALUE&gt;&lt;/NEVER&gt;&lt;/NEVER&gt;&lt;/P&gt;

&lt;P&gt;Additional Information:&lt;BR /&gt;
    Privileges      -"&lt;/P&gt;</description>
      <pubDate>Fri, 26 Dec 2014 08:48:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165229#M46936</guid>
      <dc:creator>basanthp</dc:creator>
      <dc:date>2014-12-26T08:48:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165230#M46937</link>
      <description>&lt;P&gt;Another option would be to take a look at the docs about Windows event monitoring &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/Data/MonitorWindowsdata"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/Data/MonitorWindowsdata&lt;/A&gt; and use the &lt;CODE&gt;renderXml&lt;/CODE&gt; option instead of any regex ....&lt;/P&gt;</description>
      <pubDate>Fri, 26 Dec 2014 09:24:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165230#M46937</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2014-12-26T09:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165231#M46938</link>
      <description>&lt;P&gt;MuS's comment is a good one.  If you insist on using regex, however, this string should get you started:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=Message "Subject:[\s]+?Security ID: (?&amp;lt;myfield1&amp;gt;\S+)[\s\S]+?New Account:[\s]+?Security ID: (?&amp;lt;myfield2&amp;gt;\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Dec 2014 13:50:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165231#M46938</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2014-12-26T13:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165232#M46939</link>
      <description>&lt;P&gt;Question:  Why do you not use the fields below as they already have the data you're looking for? (Account Name, Domain Name)&lt;/P&gt;

&lt;P&gt;This will allow you to use the data in either the entirety (SecurityID), or in parts (Account/Domain Name).  Just saying.&lt;/P&gt;

&lt;P&gt;Otherwise, if it's just regex practice you could do something like richgalloway posted.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Dec 2014 21:27:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165232#M46939</guid>
      <dc:creator>ltrand</dc:creator>
      <dc:date>2014-12-26T21:27:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165233#M46940</link>
      <description>&lt;P&gt;@MuS, not sure if renderXml option will impact the existing 50+ reports created using events in plain text format&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2014 05:08:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165233#M46940</guid>
      <dc:creator>basanthp</dc:creator>
      <dc:date>2014-12-30T05:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165234#M46941</link>
      <description>&lt;P&gt;@richgalloway, thanks for the above regex statement. But unfortunately they are not working, myfield1 and myfield2 are blank.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2014 05:09:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165234#M46941</guid>
      <dc:creator>basanthp</dc:creator>
      <dc:date>2014-12-30T05:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165235#M46942</link>
      <description>&lt;P&gt;@Itrand, the SecurityID in the Subject para is PerformingUserID and SecurityID in the New Account para is ImpactedUserID. And splunk recognizes both theses values under single field named SecurityID. Hence the need for separate regex.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Dec 2014 05:12:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165235#M46942</guid>
      <dc:creator>basanthp</dc:creator>
      <dc:date>2014-12-30T05:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract fields with multiple values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165236#M46943</link>
      <description>&lt;P&gt;The following works better&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=Message "Subject:[\s]+?Security ID:[\s]+(?&amp;lt;myfield1&amp;gt;\S+)[\s\S]+?New Account:[\s]+?Security ID:[\s]+(?&amp;lt;myfield2&amp;gt;\S+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Aug 2016 04:38:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-fields-with-multiple-values/m-p/165236#M46943</guid>
      <dc:creator>rathjunk</dc:creator>
      <dc:date>2016-08-09T04:38:27Z</dc:date>
    </item>
  </channel>
</rss>

