<?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 do I use regex to extract value in parenthesis preceded by parenthesis? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239428#M188749</link>
    <description>&lt;P&gt;Thank you so much @wrangler2x and @Mus. That worked perfectly.&lt;/P&gt;</description>
    <pubDate>Thu, 24 Sep 2015 22:39:48 GMT</pubDate>
    <dc:creator>aramakrishnan</dc:creator>
    <dc:date>2015-09-24T22:39:48Z</dc:date>
    <item>
      <title>How do I use regex to extract value in parenthesis preceded by parenthesis?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239423#M188744</link>
      <description>&lt;P&gt;I have the following log(s) from which I want to extract the value inside the parenthesis. The parenthesis field is preceded by 2 other values in parenthesis, and is followed by the statement "No activation date"&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{2015-09-24} {465456] [N1234SYS04] No activation date and no log bytes available.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to extract the value in the 3rd paranethesis (i.e. N1234SYS04) as it is a valuable ID field that is not getting parsed into a field on Splunk. I'd like to use the regex command but I'm not sure what my syntax should be (rex field = _raw(......))&lt;/P&gt;

&lt;P&gt;Any help would be great. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 21:56:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239423#M188744</guid>
      <dc:creator>aramakrishnan</dc:creator>
      <dc:date>2015-09-24T21:56:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use regex to extract value in parenthesis preceded by parenthesis?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239424#M188745</link>
      <description>&lt;P&gt;Hi aramakrishnan,&lt;/P&gt;

&lt;P&gt;you can try this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here | rex field=_raw "\[(?&amp;lt;ID&amp;gt;[^\]]*)" | do further splunk fu with ID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 22:01:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239424#M188745</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-24T22:01:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use regex to extract value in parenthesis preceded by parenthesis?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239425#M188746</link>
      <description>&lt;P&gt;This extracts the field but the issue is that there are actually 2 other fields that are preceded by the field I want, which also have the same format i.e. [2015-09-24][465456][N1234SYS04]. Using the rex syntax you provided pulls information from the first one, but I want it from the 3rd parenthesis (i.e. I want the field to only show N1234SYS04, but currently its showing 2015-09-24). How can I specify which parenthesis I want to start the extraction from?&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 22:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239425#M188746</guid>
      <dc:creator>aramakrishnan</dc:creator>
      <dc:date>2015-09-24T22:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use regex to extract value in parenthesis preceded by parenthesis?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239426#M188747</link>
      <description>&lt;P&gt;tested and working with this regex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/opt/splunk/bin/splunk cmd pcregextest mregex="(\[[^\]]*\]){2}\[(?&amp;lt;ID&amp;gt;[^\]]*)" test_str="[2015-09-24][465456][N1234SYS04]. 
&amp;gt; "

Original Pattern: '(\[[^\]]*\]){2}\[(?&amp;lt;ID&amp;gt;[^\]]*)'
Expanded Pattern: '(\[[^\]]*\]){2}\[(?&amp;lt;ID&amp;gt;[^\]]*)'
Regex compiled successfully. Capture group count = 2. Named capturing groups = 1.
SUCCESS - match against: '[2015-09-24][465456][N1234SYS04]. 
'

#### Capturing group data ##### 
Group |            Name | Value
--------------------------------------
    1 |                 | [465456]
    2 |              ID | N1234SYS04
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;so use it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search here | rex field=_raw "(\[[^\]]*\]){2}\[(?&amp;lt;ID&amp;gt;[^\]]*)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2015 22:18:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239426#M188747</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-09-24T22:18:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use regex to extract value in parenthesis preceded by parenthesis?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239427#M188748</link>
      <description>&lt;P&gt;The original example you gave shows {} for the first, {] for the second, and [] for the third. With that data sample @Mus rex would work perfectly.&lt;/P&gt;

&lt;P&gt;If in fact you have [] [] [] then you can modify Mus rex this way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=_raw "\[.*?\]\s+\[.*?\]\s+\[(?&amp;lt;ID&amp;gt;[^\]]*)" | stats count by ID
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Sep 2015 22:36:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239427#M188748</guid>
      <dc:creator>wrangler2x</dc:creator>
      <dc:date>2015-09-24T22:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I use regex to extract value in parenthesis preceded by parenthesis?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239428#M188749</link>
      <description>&lt;P&gt;Thank you so much @wrangler2x and @Mus. That worked perfectly.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Sep 2015 22:39:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-use-regex-to-extract-value-in-parenthesis-preceded-by/m-p/239428#M188749</guid>
      <dc:creator>aramakrishnan</dc:creator>
      <dc:date>2015-09-24T22:39:48Z</dc:date>
    </item>
  </channel>
</rss>

