<?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 you make a regular expression to extract the first 4 words in a sentence? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420686#M120883</link>
    <description>&lt;P&gt;Hi @dojiepreji&lt;/P&gt;

&lt;P&gt;Please try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval sample="The team performs checks for the following dashboards" 
| rex field=sample "(?P&amp;lt;output&amp;gt;(?:\S+\s){3}\S*).*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 Jan 2019 14:16:09 GMT</pubDate>
    <dc:creator>vnravikumar</dc:creator>
    <dc:date>2019-01-22T14:16:09Z</dc:date>
    <item>
      <title>How do you make a regular expression to extract the first 4 words in a sentence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420683#M120880</link>
      <description>&lt;P&gt;I need to extract the first 4 words in a field with sample data like this, &lt;/P&gt;

&lt;P&gt;"The team performs checks for the following dashboards".&lt;/P&gt;

&lt;P&gt;What I want is to extract the first 4 words, like so, &lt;/P&gt;

&lt;P&gt;"The team performs checks". &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=long_description ^(?&amp;lt;field1&amp;gt;\w+\s\d+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've made a rex command that will extract the first word. However, I'm having difficulty figuring out how to extract the first 4 words.&lt;/P&gt;

&lt;P&gt;Can anybody please help me out?&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jan 2019 10:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420683#M120880</guid>
      <dc:creator>dojiepreji</dc:creator>
      <dc:date>2019-01-22T10:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a regular expression to extract the first 4 words in a sentence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420684#M120881</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;|makeresults
|eval string="The team performs checks for the following dashboards"
| rex field=string "(?&amp;lt;output&amp;gt;\w+\s+\w+\s+\w+\s+\w+).+"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 13:48:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420684#M120881</guid>
      <dc:creator>saurabhkharkar</dc:creator>
      <dc:date>2019-01-22T13:48:59Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a regular expression to extract the first 4 words in a sentence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420685#M120882</link>
      <description>&lt;P&gt;Do you want the first 4 words in a single field or multiple fields.  @saurabhkharkar's answer will put them into a single field.  To get them in multiple fields, try this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=long_description "(?&amp;lt;word1&amp;gt;\w+)\W+(?&amp;lt;word2&amp;gt;\w+)\W+(?&amp;lt;word3&amp;gt;\w+)\W+(?&amp;lt;word4&amp;gt;\w+)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 13:58:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420685#M120882</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-01-22T13:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you make a regular expression to extract the first 4 words in a sentence?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420686#M120883</link>
      <description>&lt;P&gt;Hi @dojiepreji&lt;/P&gt;

&lt;P&gt;Please try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval sample="The team performs checks for the following dashboards" 
| rex field=sample "(?P&amp;lt;output&amp;gt;(?:\S+\s){3}\S*).*"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Jan 2019 14:16:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-make-a-regular-expression-to-extract-the-first-4/m-p/420686#M120883</guid>
      <dc:creator>vnravikumar</dc:creator>
      <dc:date>2019-01-22T14:16:09Z</dc:date>
    </item>
  </channel>
</rss>

