<?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: Extract strings preceded by specific characters, find only the first match per event. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346648#M102655</link>
    <description>&lt;P&gt;Hey &lt;/P&gt;

&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=your_index | field=_raw “Seg\s(?P&amp;lt;seg&amp;gt;[^\s]*)”
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2017 20:28:08 GMT</pubDate>
    <dc:creator>mayurr98</dc:creator>
    <dc:date>2017-12-15T20:28:08Z</dc:date>
    <item>
      <title>Extract strings preceded by specific characters, find only the first match per event.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346646#M102653</link>
      <description>&lt;P&gt;Sorry, this is more of a regex question but can't figure it out myself. I would like to extract a string preceded by the specific characters "Leg x Seg" where x can be any number. The strings to be extracted can have alpha numeric, dots, or underscore characters. Also, find only the first extraction match so there are no duplicate values per log. So from the single event log example below, the strings I'm looking to extract are:&lt;/P&gt;

&lt;P&gt;S3R.VPLS92966&lt;BR /&gt;
EDBK766V0001&lt;BR /&gt;
P125018_NNI_QBKW5ZP&lt;BR /&gt;
EDBK49MH0001 &lt;/P&gt;

&lt;P&gt;Event:&lt;BR /&gt;
Summary Leg 3 Seg S3R.VPLS92966 Site PBY CNGHDR JuniperJUNIPER_MX SLOT 3 CARD 2 PORT 0 TAGTYPE vlan TAG 22 STACKINGMODE none Leg 3 Seg S3R.VPLS92966 Site PBY GNBRD9 FujitsuFujitsu9500 SHELF 1 SLOT 1 PORT 1 TAGTYPE vlan TAG 22 STACKINGMODE none Leg 2 Seg EDBK766V0001 Site PBY GNBRD9 FujitsuFujitsu9500 SHELF 1 SLOT 14 PORT 15 TAGTYPE vlan TAG 49 STACKINGMODE stacked STACKEDTAGNUM 31 Leg 2 Seg EDBK766V0001 Site XTRILEC228PHLAPALO XTRILEC 228 PHLAPALO virtualswitchVirtualSeries SLOT 1 PORT 15 TAGTYPE vlan TAG 49 STACKINGMODE stacked STACKEDTAGNUM 31 Leg 2 Seg EDBK766V0001 Site XTRILEC228PHLAPALO XTRILEC 228 PHLAPALO Leg 1 Seg P125018_NNI_QBKW5ZP Site XTRILEC228DWTWPADT XTRILEC 228 DWTWPADT virtualswitchVirtualSeries SLOT 1 PORT 4 TAGTYPE vlan TAG 49 STACKINGMODE stacked STACKEDTAGNUM 31 Leg 1 Seg P125018_NNI_QBKW5ZP Site XTRILEC228DWTWPADT XTRILEC 228 DWTWPADT Leg 1 Seg P125018_NNI_QBKW5ZP Site C0LUMB P125018 OvertureOVERTURE_ISG SLOT 0 PORT 4 TAGTYPE vlan TAG 49 STACKINGMODE none Leg 0 Seg EDBK49MH0001 Site C0LUMB P125018 OvertureOVERTURE_ISG SLOT 0 PORT 1 TAGTYPE transparent TAG 0 STACKINGMODE none Leg 0 Seg EDBK49MH0001 Leg 1 Seg P125018_NNI_QBKW5ZP Leg 2 Seg EDBK766V0001 Leg 3 Seg S3R.VPLS92966 &lt;/P&gt;

&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:17:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346646#M102653</guid>
      <dc:creator>christopheryu</dc:creator>
      <dc:date>2020-09-29T17:17:48Z</dc:date>
    </item>
    <item>
      <title>Re: Extract strings preceded by specific characters, find only the first match per event.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346647#M102654</link>
      <description>&lt;P&gt;In addition, I would be counting the total number of each extracted string from a set of logs so not sure if the strings should be extracted as a single field? Illustration below:&lt;/P&gt;

&lt;P&gt;event log 1 extracted strings:&lt;BR /&gt;
S3R.VPLS92966&lt;BR /&gt;
EDBK766V0001&lt;BR /&gt;
P125018_NNI_QBKW5ZP&lt;BR /&gt;
EDBK49MH0001&lt;/P&gt;

&lt;P&gt;event log 2 extracted strings:&lt;BR /&gt;
S3R.VPLS92966&lt;BR /&gt;
BDEDBK76V00&lt;BR /&gt;
P125018_NNI_QBKW5ZP&lt;/P&gt;

&lt;P&gt;event log 3 extracted strings:&lt;BR /&gt;
BDEDBK76V00&lt;BR /&gt;
P125018_NNI_QBKW5ZP&lt;BR /&gt;
EDBK49MH0001&lt;/P&gt;

&lt;P&gt;Desired result:&lt;/P&gt;

&lt;P&gt;string                                      count&lt;BR /&gt;
S3R.VPLS92966                     2&lt;BR /&gt;
EDBK766V0001                     1&lt;BR /&gt;
P125018_NNI_QBKW5ZP    3&lt;BR /&gt;
EDBK49MH0001                   2&lt;BR /&gt;
BDEDBK76V00                      2&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:17:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346647#M102654</guid>
      <dc:creator>christopheryu</dc:creator>
      <dc:date>2020-09-29T17:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Extract strings preceded by specific characters, find only the first match per event.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346648#M102655</link>
      <description>&lt;P&gt;Hey &lt;/P&gt;

&lt;P&gt;Try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=your_index | field=_raw “Seg\s(?P&amp;lt;seg&amp;gt;[^\s]*)”
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know if this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2017 20:28:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346648#M102655</guid>
      <dc:creator>mayurr98</dc:creator>
      <dc:date>2017-12-15T20:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: Extract strings preceded by specific characters, find only the first match per event.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346649#M102656</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval _raw="Summary Leg 3 Seg S3R.VPLS92966 Site PBY CNGHDR JuniperJUNIPER_MX SLOT 3 CARD 2 PORT 0 TAGTYPE vlan TAG 22 STACKINGMODE none Leg 3 Seg S3R.VPLS92966 Site PBY GNBRD9 FujitsuFujitsu9500 SHELF 1 SLOT 1 PORT 1 TAGTYPE vlan TAG 22 STACKINGMODE none Leg 2 Seg EDBK766V0001 Site PBY GNBRD9 FujitsuFujitsu9500 SHELF 1 SLOT 14 PORT 15 TAGTYPE vlan TAG 49 STACKINGMODE stacked STACKEDTAGNUM 31 Leg 2 Seg EDBK766V0001 Site XTRILEC228PHLAPALO XTRILEC 228 PHLAPALO virtualswitchVirtualSeries SLOT 1 PORT 15 TAGTYPE vlan TAG 49 STACKINGMODE stacked STACKEDTAGNUM 31 Leg 2 Seg EDBK766V0001 Site XTRILEC228PHLAPALO XTRILEC 228 PHLAPALO Leg 1 Seg P125018_NNI_QBKW5ZP Site XTRILEC228DWTWPADT XTRILEC 228 DWTWPADT virtualswitchVirtualSeries SLOT 1 PORT 4 TAGTYPE vlan TAG 49 STACKINGMODE stacked STACKEDTAGNUM 31 Leg 1 Seg P125018_NNI_QBKW5ZP Site XTRILEC228DWTWPADT XTRILEC 228 DWTWPADT Leg 1 Seg P125018_NNI_QBKW5ZP Site C0LUMB P125018 OvertureOVERTURE_ISG SLOT 0 PORT 4 TAGTYPE vlan TAG 49 STACKINGMODE none Leg 0 Seg EDBK49MH0001 Site C0LUMB P125018 OvertureOVERTURE_ISG SLOT 0 PORT 1 TAGTYPE transparent TAG 0 STACKINGMODE none Leg 0 Seg EDBK49MH0001 Leg 1 Seg P125018_NNI_QBKW5ZP Leg 2 Seg EDBK766V0001 Leg 3 Seg S3R.VPLS92966"
| rex max_match=0 "Leg\s+\d+\s+Seg\s+(?&amp;lt;NewField&amp;gt;\S+)"
| eval NewField=mvdedup(NewField)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Dec 2017 23:19:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346649#M102656</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-12-16T23:19:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract strings preceded by specific characters, find only the first match per event.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346650#M102657</link>
      <description>&lt;P&gt;And then add the following - for number of Ocurrences ..&lt;/P&gt;

&lt;P&gt;| mvexpand NewField | stats count as Occurences by NewField&lt;/P&gt;</description>
      <pubDate>Sun, 17 Dec 2017 22:53:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-strings-preceded-by-specific-characters-find-only-the/m-p/346650#M102657</guid>
      <dc:creator>Esky73</dc:creator>
      <dc:date>2017-12-17T22:53:51Z</dc:date>
    </item>
  </channel>
</rss>

