<?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 content of brackets in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481804#M135016</link>
    <description>&lt;P&gt;Hi @mehrdad_2000,&lt;/P&gt;

&lt;P&gt;If you just want whatever is between square brackets but ensuring it only contains letters and not numbers, you can do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=1 "^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\,\d{3} \w+ [\w\-\.]+ \[(?&amp;lt;myField&amp;gt;[a-zA-Z]+)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For instance, if I use your sample data:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8752i68550168700E3F77/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2020 08:58:16 GMT</pubDate>
    <dc:creator>javiergn</dc:creator>
    <dc:date>2020-04-22T08:58:16Z</dc:date>
    <item>
      <title>extract content of brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481803#M135015</link>
      <description>&lt;P&gt;how can i extract content of first bracket if it is string?&lt;/P&gt;

&lt;P&gt;e.g:&lt;BR /&gt;
2020-04-21 23:59:59,093 INFO  xxx.xxx-zz-00000 [process] start[ppp] time[00] tag[xxx]&lt;BR /&gt;
2020-04-21 23:59:59,093 INFO  xxx.xxx-zz-00000 [1234567] start[ppp] time[00] tag[xxx]&lt;BR /&gt;
....&lt;/P&gt;

&lt;P&gt;expected result:&lt;BR /&gt;
process&lt;/P&gt;

&lt;P&gt;have huge log file need to extract process with this conditions&lt;BR /&gt;
1-content of first bracket&lt;BR /&gt;
2-it must be string not number!&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 05:45:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481803#M135015</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2020-04-22T05:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: extract content of brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481804#M135016</link>
      <description>&lt;P&gt;Hi @mehrdad_2000,&lt;/P&gt;

&lt;P&gt;If you just want whatever is between square brackets but ensuring it only contains letters and not numbers, you can do something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex max_match=1 "^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\,\d{3} \w+ [\w\-\.]+ \[(?&amp;lt;myField&amp;gt;[a-zA-Z]+)\]"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For instance, if I use your sample data:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/8752i68550168700E3F77/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 08:58:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481804#M135016</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2020-04-22T08:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: extract content of brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481805#M135017</link>
      <description>&lt;P&gt;As I mentioned this is large log file and need more complete regex to do this.&lt;BR /&gt;
For example your answer extract only fixed pattern that i mention, but not work on these:&lt;/P&gt;

&lt;P&gt;2020-04-21 23:59:59,093 INFO xxxx.xxxxx-zz-00000xxx111 [process] start[ppp] time[00] tag[xxx]&lt;BR /&gt;
2020-04-21 23:59:59,093 INFO xx.xxx-zz-00000x [report] start[ppp] time[00] tag[xxx]&lt;/P&gt;

&lt;P&gt;Expected output:&lt;BR /&gt;
process&lt;BR /&gt;
report&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 12:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481805#M135017</guid>
      <dc:creator>indeed_2000</dc:creator>
      <dc:date>2020-04-22T12:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: extract content of brackets</title>
      <link>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481806#M135018</link>
      <description>&lt;P&gt;Hmm, that's interesting. I have tested both your samples on regex101 and my regex works fine with them. Look:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/cjjSHZ/1"&gt;https://regex101.com/r/cjjSHZ/1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 13:04:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/extract-content-of-brackets/m-p/481806#M135018</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2020-04-23T13:04:54Z</dc:date>
    </item>
  </channel>
</rss>

