<?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: With regex, can you help us extract the first word that comes after the timestamp? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447087#M126762</link>
    <description>&lt;P&gt;Thanks Vijeta....&lt;BR /&gt;
I am wondering how to implement it....&lt;BR /&gt;
Instead of  .......|appendpipe[|eval x="2019-02-05 19: ...........&lt;BR /&gt;
I replaced with ...|appendpipe[|eval x=_raw ...........&lt;BR /&gt;
so it will scan it all events ...but it gives many errors&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex host=myhost sourcetype="my.source.type"  |makeresults| eval x=_raw |appendpipe[|eval x=_raw]| rex field=x "\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3}\s{0,1}\w{0,3}\s(?&amp;lt;level&amp;gt;\w+)" | table level
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Feb 2019 16:05:52 GMT</pubDate>
    <dc:creator>zacksoft</dc:creator>
    <dc:date>2019-02-06T16:05:52Z</dc:date>
    <item>
      <title>With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447082#M126757</link>
      <description>&lt;P&gt;I wanted to extract the first word that comes after the timestamp.&lt;/P&gt;

&lt;P&gt;The time stamps are of varied formats&lt;/P&gt;

&lt;P&gt;example event1 :&lt;BR /&gt;&lt;BR /&gt;
2019-02-05 11:89:17,642 EST &lt;STRONG&gt;BROCOD&lt;/STRONG&gt; bla bla bla ......&lt;/P&gt;

&lt;P&gt;example event2 :&lt;BR /&gt;&lt;BR /&gt;
2019-02-05 19:35:18,642 &lt;STRONG&gt;MARC&lt;/STRONG&gt; bla bla bla........ &lt;/P&gt;

&lt;P&gt;I wanted to parse BROCOD and MARC&lt;/P&gt;

&lt;P&gt;I tried the following....it should work..but I'm not sure why it is not showing me any result&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "^(?:[^ \n]* ){3}(?P&amp;lt;level&amp;gt;\w+)" | table  level 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 15:35:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447082#M126757</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-06T15:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447083#M126758</link>
      <description>&lt;P&gt;You can check this out - &lt;A href="https://regex101.com/r/cQF8aS/1"&gt;https://regex101.com/r/cQF8aS/1&lt;/A&gt;&lt;BR /&gt;
You need something like&lt;/P&gt;

&lt;P&gt;^.*,\d+\s+(?:EST)?\s?(?\w+)&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 15:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447083#M126758</guid>
      <dc:creator>lakshman239</dc:creator>
      <dc:date>2019-02-06T15:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447084#M126759</link>
      <description>&lt;P&gt;Thanks  Lakshman.&lt;BR /&gt;
When I try this it says "unrecognized character after (? or (?-"&lt;BR /&gt;
Also what is the field name where the extraction is getting stored at?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 15:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447084#M126759</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-06T15:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447085#M126760</link>
      <description>&lt;P&gt;Hey zacksoft, &lt;/P&gt;

&lt;P&gt;this one is a bit complicated as you can never be sure if ther will be an abbreviated timezone or not. &lt;/P&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/n1RYOu/2"&gt;https://regex101.com/r/n1RYOu/2&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;So I found this solution for you, which might look a bit convuluted at first, but basically matches all the possible time-zone-abbreviations we have at the moment. And only, if they are there.&lt;/P&gt;

&lt;P&gt;So please give it a careful look and ask me questions about it if you have any. &lt;/P&gt;

&lt;P&gt;Regards, &lt;BR /&gt;
pyro_wood&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 15:56:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447085#M126760</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2019-02-06T15:56:12Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447086#M126761</link>
      <description>&lt;P&gt;I tried below and worked for me &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=x "\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3}\s{0,1}\w{0,3}\s(?&amp;lt;level&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|makeresults| eval x="2019-02-05 11:89:17,642 EST BROCOD bla bla bla" |appendpipe[|eval x="2019-02-05 19:35:18,642 MARC bla bla bla"]| rex field=x "\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3}\s{0,1}\w{0,3}\s(?&amp;lt;level&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 15:56:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447086#M126761</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-06T15:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447087#M126762</link>
      <description>&lt;P&gt;Thanks Vijeta....&lt;BR /&gt;
I am wondering how to implement it....&lt;BR /&gt;
Instead of  .......|appendpipe[|eval x="2019-02-05 19: ...........&lt;BR /&gt;
I replaced with ...|appendpipe[|eval x=_raw ...........&lt;BR /&gt;
so it will scan it all events ...but it gives many errors&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex host=myhost sourcetype="my.source.type"  |makeresults| eval x=_raw |appendpipe[|eval x=_raw]| rex field=x "\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3}\s{0,1}\w{0,3}\s(?&amp;lt;level&amp;gt;\w+)" | table level
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:05:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447087#M126762</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-06T16:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447088#M126763</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/109956"&gt;@horsefez&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;Just to confirm this is the regex right ? I am a bit new to this regex arena !!&lt;/P&gt;

&lt;P&gt;index=DEMOhost=anything sourcetype="something.something" &lt;BR /&gt;
rex "^\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2},\d+\s(?:\b(?:ACDT|ACST|ACT|ACT|ACWST|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|AMT|ART|AST|AST|AWST|AZOST|AZOT|AZT|BDT|BIOT|BIT|BOT|BRST|BRT|BST|BST|BST|BTT|CAT|CCT|CDT|CDT|CEST|CET|CHADT|CHAST|CHOT|CHOST|CHST|CHUT|CIST|CIT|CKT|CLST|CLT|COST|COT|CST|CST|CST|CT|CVT|CWST|CXT|DAVT|DDUT|DFT|EASST|EAST|EAT|ECT|ECT|EDT|EEST|EET|EGST|EGT|EIT|EST|FET|FJT|FKST|FKT|FNT|GALT|GAMT|GET|GFT|GILT|GIT|GMT|GST|GST|GYT|HDT|HAEC|HST|HKT|HMT|HOVST|HOVT|ICT|IDLW|IDT|IOT|IRDT|IRKT|IRST|IST|IST|IST|JST|KALT|KGT|KOST|KRAT|KST|LHST|LHST|LINT|MAGT|MART|MAWT|MDT|MET|MEST|MHT|MIST|MIT|MMT|MSK|MST|MST|MUT|MVT|MYT|NCT|NDT|NFT|NPT|NST|NT|NUT|NZDT|NZST|OMST|ORAT|PDT|PET|PETT|PGT|PHOT|PHT|PKT|PMDT|PMST|PONT|PST|PST|PYST|PYT|RET|ROTT|SAKT|SAMT|SAST|SBT|SCT|SDT|SGT|SLST|SRET|SRT|SST|SST|SYOT|TAHT|THA|TFT|TJT|TKT|TLT|TMT|TRT|TOT|TVT|ULAST|ULAT|UTC|UYST|UYT|UZT|VET|VLAT|VOLT|VOST|VUT|WAKT|WAST|WAT|WEST|WET|WIT|WST|YAKT|YEKT)\b\s*)?(?\w+)" &lt;BR /&gt;
 | table match&lt;/P&gt;

&lt;P&gt;If, yes I tried this..but it yielded no result !!!   &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:05:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447088#M126763</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2020-09-29T23:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447089#M126764</link>
      <description>&lt;P&gt;Hi @zacksoft, &lt;/P&gt;

&lt;P&gt;try this one and tell me if it works.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=DEMO host=anything sourcetype=something 
| rex "^\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2},\d+\s(?:\b(?:ACDT|ACST|ACT|ACT|ACWST|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|AMT|ART|AST|AST|AWST|AZOST|AZOT|AZT|BDT|BIOT|BIT|BOT|BRST|BRT|BST|BST|BST|BTT|CAT|CCT|CDT|CDT|CEST|CET|CHADT|CHAST|CHOT|CHOST|CHST|CHUT|CIST|CIT|CKT|CLST|CLT|COST|COT|CST|CST|CST|CT|CVT|CWST|CXT|DAVT|DDUT|DFT|EASST|EAST|EAT|ECT|ECT|EDT|EEST|EET|EGST|EGT|EIT|EST|FET|FJT|FKST|FKT|FNT|GALT|GAMT|GET|GFT|GILT|GIT|GMT|GST|GST|GYT|HDT|HAEC|HST|HKT|HMT|HOVST|HOVT|ICT|IDLW|IDT|IOT|IRDT|IRKT|IRST|IST|IST|IST|JST|KALT|KGT|KOST|KRAT|KST|LHST|LHST|LINT|MAGT|MART|MAWT|MDT|MET|MEST|MHT|MIST|MIT|MMT|MSK|MST|MST|MUT|MVT|MYT|NCT|NDT|NFT|NPT|NST|NT|NUT|NZDT|NZST|OMST|ORAT|PDT|PET|PETT|PGT|PHOT|PHT|PKT|PMDT|PMST|PONT|PST|PST|PYST|PYT|RET|ROTT|SAKT|SAMT|SAST|SBT|SCT|SDT|SGT|SLST|SRET|SRT|SST|SST|SYOT|TAHT|THA|TFT|TJT|TKT|TLT|TMT|TRT|TOT|TVT|ULAST|ULAT|UTC|UYST|UYT|UZT|VET|VLAT|VOLT|VOST|VUT|WAKT|WAST|WAT|WEST|WET|WIT|WST|YAKT|YEKT)\b\s*)?(?&amp;lt;level&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:18:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447089#M126764</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2019-02-06T16:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447090#M126765</link>
      <description>&lt;P&gt;@zacksoft - did you try the below&lt;/P&gt;

&lt;P&gt;You need not use makeresults, it was just for creating sample events for me. Your query can be-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=myIndex host=myhost sourcetype="my.source.type"  |rex field=_raw "\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2},\d{3}\s{0,1}\w{0,3}\s(?&amp;lt;level&amp;gt;\w+)" | table level
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:20:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447090#M126765</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-06T16:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447091#M126766</link>
      <description>&lt;P&gt;@pyro_wood - This is the most insane looking query. But it is awesome.. it works perfectly ......&lt;BR /&gt;
You're a genius. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:23:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447091#M126766</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-06T16:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447092#M126767</link>
      <description>&lt;P&gt;@zacksoft, &lt;/P&gt;

&lt;P&gt;I agree that it looks complicated at first and I'm glad that it works out for you.&lt;/P&gt;

&lt;P&gt;But it's not so complicated. &lt;BR /&gt;
I will explain to you why it isn't as complicated as it might look.&lt;BR /&gt;
&lt;CODE&gt;^&lt;/CODE&gt; this is called an anchor, and points to the start of the line (will always be there)&lt;BR /&gt;
&lt;CODE&gt;\d{4}-\d{2}-\d{2}\s*\d{2}:\d{2}:\d{2},\d+\s*&lt;/CODE&gt; this traverses over the date and timefields (will always be there)&lt;BR /&gt;
&lt;CODE&gt;(?:\b(?:ACDT|ACST|ACT|ACWST...|BOT|...|WST|YAKT|YEKT)\b\s*)?&lt;/CODE&gt; this will look for a valid timezone abbreviation. A list of all valid timezone abbreviations I found on the web.&lt;BR /&gt;
It basically is a &lt;CODE&gt;OR&lt;/CODE&gt;-list. If it doesn't find ACDT, it will look if it finds ACST, if not it looks if it finds ACT and so on. The very last &lt;CODE&gt;?&lt;/CODE&gt; question mark makes the entire statement that is encased in paranteshis optional. It means, that the timezone might be there or not. (optional)&lt;BR /&gt;
&lt;CODE&gt;(?&amp;lt;level&amp;gt;\w+)&lt;/CODE&gt; regardless of the existence of the optional timezone field, the field that matches your text comes afterwards (will always be there)&lt;/P&gt;

&lt;P&gt;You might have notice the &lt;CODE&gt;\b&lt;/CODE&gt; in the regex. &lt;CODE&gt;\b&lt;/CODE&gt; marks a word-boundary. Long story short it makes sure that the timezone matching instruction doesn't match words like for example "ACTION", "BOTTOM", "PETS", "PHOTO" or "WESTWARDS". &lt;/P&gt;

&lt;P&gt;Hope this helps a bit. &lt;BR /&gt;
Regards, &lt;BR /&gt;
pyro_wood&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:38:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447092#M126767</guid>
      <dc:creator>horsefez</dc:creator>
      <dc:date>2019-02-06T16:38:14Z</dc:date>
    </item>
    <item>
      <title>Re: With regex, can you help us extract the first word that comes after the timestamp?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447093#M126768</link>
      <description>&lt;P&gt;Thanks for explaining each step. Now I understand.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 16:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/With-regex-can-you-help-us-extract-the-first-word-that-comes/m-p/447093#M126768</guid>
      <dc:creator>zacksoft</dc:creator>
      <dc:date>2019-02-06T16:49:13Z</dc:date>
    </item>
  </channel>
</rss>

