<?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 multiple email addresses into one field where each email is followed by an IP address? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137223#M37585</link>
    <description>&lt;P&gt;Yes, That would be the reason. Try the somesoni2 method. That should work. Or else try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "\s+(?P&amp;lt;Email&amp;gt;\S+@\S+)\s+\((?P&amp;lt;IPADDRESS&amp;gt;\d+\.\d+\.\d+\.\d+)\)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 23 Sep 2014 22:34:41 GMT</pubDate>
    <dc:creator>theouhuios</dc:creator>
    <dc:date>2014-09-23T22:34:41Z</dc:date>
    <item>
      <title>How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137218#M37580</link>
      <description>&lt;P&gt;I want to extract a field that has multiple email addresses, each one followed by an IP address, all of which appear at the very end of a MS Windows event.  My ultimate goal is to capture all of the email addresses in one field, up to the end of the event, but then remove the IP addresses, so I am left with just the email addresses.  My regexes so far will not capture beyond the first "Authorized Recipient" email address, and there could a hundred or more recipient addresses listed, depending on the size of a distro list.&lt;BR /&gt;
Here's a sample of the event, with the exact formatting for how Splunk displays it in search results:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;               Time
               LogName=etc
               EventCode=etc
               etc etc
               Message=Message Validation Success

              This action was requested by blah.blah@blah.com.    (-no problem extracting these other values to fields)

              Message Subject:

                blah

             Other info:

                blah blah

            blah text blah.

            Authorized Recipients:

                                  blah1.blah@blah.com        (000.000.000.000)     (- this is an IPv4 address)
                                  blah2.blah@blah.com        (000.000.000.000)    
                                  blah3.blah@blah.com        (000.000.000.000)
                                  etc, etc, etc.....
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's the pertinent portion of my latest regex:&lt;BR /&gt;
rex "(?m)Authorized\sRecipients:\s+(?P.*)"&lt;/P&gt;

&lt;P&gt;...but it only captures the first email address and IP under recipients.  I want to capture all of them, regardless how many are listed.&lt;BR /&gt;
I'm still a regex newbie, but I know the capture should be greedy, up to the end of the event.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 16:32:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137218#M37580</guid>
      <dc:creator>gsawyer1</dc:creator>
      <dc:date>2014-09-23T16:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137219#M37581</link>
      <description>&lt;P&gt;Use max_match = 0, which will extract multiple values for a regex expression.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "Recipients:\s+(?P&amp;lt;EMAIL&amp;gt;\S+)\s+\((?P&amp;lt;IPADDRESS&amp;gt;\d+\.\d+\.\d+\.\d+)\)" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Sep 2014 16:32:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137219#M37581</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2014-09-23T16:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137220#M37582</link>
      <description>&lt;P&gt;No joy.  The regex is still only capturing the first email recipient as the EMAIL field, even though I'm sending to multiple addresses.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 19:25:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137220#M37582</guid>
      <dc:creator>gsawyer1</dc:creator>
      <dc:date>2014-09-23T19:25:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137221#M37583</link>
      <description>&lt;P&gt;Could the issue be that the "Recipients: " portion is not repeated more than once?  The boundary, after the first recipient, changes from "Recipients:  &lt;A href="mailto:email@blah.com"&gt;email@blah.com&lt;/A&gt; (IPaddress)"  to just "&lt;A href="mailto:email@blah.com"&gt;email@blah.com&lt;/A&gt; (IPaddress)", repeated.  Should I capture the first instance, and then look for other instances afterward?  This would be conditional, as there may or may not be any additional addressees to follow.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 19:28:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137221#M37583</guid>
      <dc:creator>gsawyer1</dc:creator>
      <dc:date>2014-09-23T19:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137222#M37584</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search  |  rex field=_raw "Recipients:\s+(?P&amp;lt;DataPortion&amp;gt;.*)" | rex field=DataPortion "(?P&amp;lt;EMAIL&amp;gt;\S+)\s+\((?P&amp;lt;IPADDRESS&amp;gt;\d+\.\d+\.\d+\.\d+)\)" max_match=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Sep 2014 19:52:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137222#M37584</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-09-23T19:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137223#M37585</link>
      <description>&lt;P&gt;Yes, That would be the reason. Try the somesoni2 method. That should work. Or else try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "\s+(?P&amp;lt;Email&amp;gt;\S+@\S+)\s+\((?P&amp;lt;IPADDRESS&amp;gt;\d+\.\d+\.\d+\.\d+)\)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 23 Sep 2014 22:34:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137223#M37585</guid>
      <dc:creator>theouhuios</dc:creator>
      <dc:date>2014-09-23T22:34:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to write regex to extract multiple email addresses into one field where each email is followed by an IP address?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137224#M37586</link>
      <description>&lt;P&gt;This gives me the same issue again.  I think I get what you suggested...perform another regex on the "DataPortion" field after it has been extracted.  But all this gave me was the same data - the first address and IP address only.  I still think I need to make the regex greedy enough to just capture all of the email addresses, from the first one to any others that follow, to the end of the event - although the regex you suggest will help afterwards, once I have the capture, to strip the IP address off of the "DataPortion" field, which I actually won't need.....&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2014 13:14:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-regex-to-extract-multiple-email-addresses-into-one/m-p/137224#M37586</guid>
      <dc:creator>gsawyer1</dc:creator>
      <dc:date>2014-09-24T13:14:39Z</dc:date>
    </item>
  </channel>
</rss>

