<?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: RegEx for pattern matching and extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471746#M132737</link>
    <description>&lt;P&gt;Hi @ jpolvino,&lt;/P&gt;

&lt;P&gt;I only need SES and ABC extracted from above patterns. In last example, ABC is twice. It is same ABC but second one has additional number or a character. I will need the 9 digit ABCs only which is the middle one in last example.&lt;/P&gt;

&lt;P&gt;Sample data:&lt;BR /&gt;
1234567-123456789--- (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
1234567-1234567890-123456789-- (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345678-123456789--A12345678-123456789 (Need 9 digit ABC only, 123456789, last one)&lt;BR /&gt;
123456789 (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345678900000 (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345ac4-1234-1a12-9as9-1aa111as23aa (This I am trying to figure out with data owners to clarify this pattern)&lt;BR /&gt;
12345678900000-123456789 (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345678900000-123456789-1234567890 (Need 9 digit ABC only, 123456789, the middle one)&lt;/P&gt;</description>
    <pubDate>Wed, 15 Apr 2020 05:41:20 GMT</pubDate>
    <dc:creator>mbasharat</dc:creator>
    <dc:date>2020-04-15T05:41:20Z</dc:date>
    <item>
      <title>RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471741#M132732</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have data that contains Sessions ID labeled as (SES) and User ID labeled as (ABC). &lt;/P&gt;

&lt;P&gt;When I look at the events, I am seeing below variations. RegEx should grab anything that is 14 digits followed by 0 or more groups of dash/hyphen with 9 digits or dash/hyphen with 0 digits. I need a RegEx that extract the SES and ABC into separate fields from below variations. &lt;/P&gt;

&lt;P&gt;Formats seen:&lt;BR /&gt;
SES&lt;BR /&gt;
SES-ABC&lt;BR /&gt;
SES—ABC&lt;BR /&gt;
SES—ABC-&lt;BR /&gt;
SES-ABC-ABC&lt;/P&gt;

&lt;P&gt;Sample data:&lt;BR /&gt;
1234567-123456789---&lt;BR /&gt;
1234567-1234567890-123456789--&lt;BR /&gt;
12345678-123456789--A12345678-123456789&lt;BR /&gt;
123456789&lt;BR /&gt;
12345678900000&lt;BR /&gt;
12345ac4-1234-1a12-9as9-1aa111as23aa&lt;BR /&gt;
12345678900000-123456789&lt;BR /&gt;
12345678900000-123456789-1234567890&lt;/P&gt;

&lt;P&gt;Thanks in-advance&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 17:41:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471741#M132732</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2020-04-13T17:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471742#M132733</link>
      <description>&lt;P&gt;Hi, can you please provide a little more detail? Specifically in the examples you provide, what are the examples of SES and ABC matches you expect from the legal ones? And which of those should not match anything?&lt;/P&gt;

&lt;P&gt;When you have ABC twice (the last formats seen line) is that literally the &lt;EM&gt;same&lt;/EM&gt; ABC twice, or different ABCs?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 19:07:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471742#M132733</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-04-13T19:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471743#M132734</link>
      <description>&lt;P&gt;&lt;CODE&gt;12345ac4-1234-1a12-9as9-1aa111as23aa&lt;/CODE&gt;&lt;BR /&gt;
where is SES and ABC?&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 23:34:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471743#M132734</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-13T23:34:04Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471744#M132735</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="raw
1234567-123456789---
1234567-1234567890-123456789--
12345678-123456789--A12345678-123456789
123456789
12345678900000
12345ac4-1234-1a12-9as9-1aa111as23aa
12345678900000-123456789
12345678900000-123456789-1234567890" 
| multikv forceheader=1 
| rex max_match=2 "(?&amp;lt;SES&amp;gt;^\d+)|-(?&amp;lt;ABC&amp;gt;\d+)(?:-|$)" 
| eval SES=trim(SES,"0"), ABC=trim(ABC,"0")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;use &lt;CODE&gt;rex&lt;/CODE&gt; with limits &lt;CODE&gt;max_match&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 23:40:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471744#M132735</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-04-13T23:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471745#M132736</link>
      <description>&lt;P&gt;Hi @ t04kawa This one is a very odd pattern and I am also scratching my head when I was looking at it. Lemme try your provided solution below. Will report back shortly.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 05:36:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471745#M132736</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2020-04-15T05:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471746#M132737</link>
      <description>&lt;P&gt;Hi @ jpolvino,&lt;/P&gt;

&lt;P&gt;I only need SES and ABC extracted from above patterns. In last example, ABC is twice. It is same ABC but second one has additional number or a character. I will need the 9 digit ABCs only which is the middle one in last example.&lt;/P&gt;

&lt;P&gt;Sample data:&lt;BR /&gt;
1234567-123456789--- (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
1234567-1234567890-123456789-- (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345678-123456789--A12345678-123456789 (Need 9 digit ABC only, 123456789, last one)&lt;BR /&gt;
123456789 (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345678900000 (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345ac4-1234-1a12-9as9-1aa111as23aa (This I am trying to figure out with data owners to clarify this pattern)&lt;BR /&gt;
12345678900000-123456789 (Need 9 digit ABC only, 123456789)&lt;BR /&gt;
12345678900000-123456789-1234567890 (Need 9 digit ABC only, 123456789, the middle one)&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 05:41:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471746#M132737</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2020-04-15T05:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: RegEx for pattern matching and extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471747#M132738</link>
      <description>&lt;P&gt;After dealing with customer, data at the source is fixed. Above RegEx works perfectly now. THANK YOU!&lt;/P&gt;</description>
      <pubDate>Sun, 19 Apr 2020 03:25:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/RegEx-for-pattern-matching-and-extraction/m-p/471747#M132738</guid>
      <dc:creator>mbasharat</dc:creator>
      <dc:date>2020-04-19T03:25:48Z</dc:date>
    </item>
  </channel>
</rss>

