<?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 create a regex to extract the first IP address from multiple IP addresses in an event line? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420845#M120930</link>
    <description>&lt;P&gt;worked by removing .+ at the end ...&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jun 2019 18:19:53 GMT</pubDate>
    <dc:creator>reverse</dc:creator>
    <dc:date>2019-06-12T18:19:53Z</dc:date>
    <item>
      <title>How to create a regex to extract the first IP address from multiple IP addresses in an event line?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420842#M120927</link>
      <description>&lt;P&gt;There are multiple ip addresses in a raw event line and I only need the first one &lt;BR /&gt;
How can I achieve that?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;192.168.0.1 -192.168.0.5 gcgh 192.168.0.7gcgh 192.168.0.7 gcgh 192.168.0.8 gcgh 192.168.0.9 gcgh
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 18:02:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420842#M120927</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-06-12T18:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract the first IP address from multiple IP addresses in an event line?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420843#M120928</link>
      <description>&lt;P&gt;Something like that:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\/*\d*).+
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 18:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420843#M120928</guid>
      <dc:creator>felipesewaybric</dc:creator>
      <dc:date>2019-06-12T18:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract the first IP address from multiple IP addresses in an event line?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420844#M120929</link>
      <description>&lt;P&gt;not working .. i tried here &lt;BR /&gt;
&lt;A href="https://regex101.com/r/2MblRX/1"&gt;https://regex101.com/r/2MblRX/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 18:13:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420844#M120929</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-06-12T18:13:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract the first IP address from multiple IP addresses in an event line?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420845#M120930</link>
      <description>&lt;P&gt;worked by removing .+ at the end ...&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 18:19:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420845#M120930</guid>
      <dc:creator>reverse</dc:creator>
      <dc:date>2019-06-12T18:19:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a regex to extract the first IP address from multiple IP addresses in an event line?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420846#M120931</link>
      <description>&lt;P&gt;Adding context for anyone coming here for answers.&lt;/P&gt;

&lt;P&gt;Assuming msg is the field name, the following would result in the first IP found&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults  
| eval msg = "192.128.22.2 202.134.55.89" 
| rex field=msg "(?&amp;lt;firstip&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If additional IPs needed to be extracted then a max_match = # could be added to the rex line. &lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 18:42:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-regex-to-extract-the-first-IP-address-from/m-p/420846#M120931</guid>
      <dc:creator>jazzypai</dc:creator>
      <dc:date>2019-06-12T18:42:14Z</dc:date>
    </item>
  </channel>
</rss>

