<?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 Regex for complex search string in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234297#M69625</link>
    <description>&lt;P&gt;Search String&lt;BR /&gt;
 - Promotion Created, Coupon Settings For PromoCode=121509PromoId=3550966 &lt;STRONG&gt;: 17429150|Gillette|111082|9999999|Save $5.00 on Gillette|Save $5.00 on ONE Gillette Fusion ProShield|2016-05-29T07:00:00Z|2016-07-02T07:00:00Z|2016-07-02T07:00:00Z||811000474001215093500110100|RMS|[047400656048, 047400656055, 047400656062, 047400656079, 047400656109, 047400656116]&lt;/STRONG&gt;|[]||RetailerBanners : [Brookshire]&lt;/P&gt;

&lt;P&gt;Need to create a table as below . Column 3 as bold starts after ":" and should be seperated with Column names as 1,2..&lt;/P&gt;

&lt;P&gt;Table sample:&lt;BR /&gt;
PromoCode   PromoId Column 1    Column 2    Column 3    Column 4    Column 5    Column 6    Column 7    Column 8    Column 9    Column 10&lt;BR /&gt;
121509  3550966     17429150    Gillette    111082  9999999     Save $5.00 on Gillette  Save $5.00 on ONE Gillette Fusion ProShield 2016-04-29T07:00:00Z     2016-05-02T07:00:00Z   2016-07-02T07:00:00Z    &lt;/P&gt;</description>
    <pubDate>Sat, 07 May 2016 07:27:54 GMT</pubDate>
    <dc:creator>arunsubram</dc:creator>
    <dc:date>2016-05-07T07:27:54Z</dc:date>
    <item>
      <title>Regex for complex search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234297#M69625</link>
      <description>&lt;P&gt;Search String&lt;BR /&gt;
 - Promotion Created, Coupon Settings For PromoCode=121509PromoId=3550966 &lt;STRONG&gt;: 17429150|Gillette|111082|9999999|Save $5.00 on Gillette|Save $5.00 on ONE Gillette Fusion ProShield|2016-05-29T07:00:00Z|2016-07-02T07:00:00Z|2016-07-02T07:00:00Z||811000474001215093500110100|RMS|[047400656048, 047400656055, 047400656062, 047400656079, 047400656109, 047400656116]&lt;/STRONG&gt;|[]||RetailerBanners : [Brookshire]&lt;/P&gt;

&lt;P&gt;Need to create a table as below . Column 3 as bold starts after ":" and should be seperated with Column names as 1,2..&lt;/P&gt;

&lt;P&gt;Table sample:&lt;BR /&gt;
PromoCode   PromoId Column 1    Column 2    Column 3    Column 4    Column 5    Column 6    Column 7    Column 8    Column 9    Column 10&lt;BR /&gt;
121509  3550966     17429150    Gillette    111082  9999999     Save $5.00 on Gillette  Save $5.00 on ONE Gillette Fusion ProShield 2016-04-29T07:00:00Z     2016-05-02T07:00:00Z   2016-07-02T07:00:00Z    &lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2016 07:27:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234297#M69625</guid>
      <dc:creator>arunsubram</dc:creator>
      <dc:date>2016-05-07T07:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for complex search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234298#M69626</link>
      <description>&lt;P&gt;Try (not complete, add as many as required...)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=a_field "^[^\:]+\:(?&amp;lt;field1&amp;gt;[^\|]+)\|(?&amp;lt;field2&amp;gt;[^\|]+)\|(?&amp;lt;field3&amp;gt;[^\|]+)\|"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Some explanation to help you extend it and understand it.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;^[^\:]+\:&lt;/CODE&gt; says to start at the beginning (first &lt;CODE&gt;^&lt;/CODE&gt; ) and read one or more &lt;CODE&gt;+&lt;/CODE&gt; characters not matching a colon ( &lt;CODE&gt;[^\:]&lt;/CODE&gt; ).&lt;BR /&gt;
Then, &lt;CODE&gt;(?&amp;lt;field1&amp;gt;&lt;/CODE&gt; create an extraction named "field1" which reads one or more characters that are not a pipe symbol &lt;CODE&gt;[^\|]+&lt;/CODE&gt; then close the extraction piece &lt;CODE&gt;)&lt;/CODE&gt; . &lt;BR /&gt;
Now, between fields there will be a pipe symbol, find that.  &lt;CODE&gt;\|&lt;/CODE&gt; then start the next extraction group &lt;CODE&gt;(?&amp;lt;field2&amp;gt;[^\|]+)&lt;/CODE&gt; and repeat.&lt;/P&gt;

&lt;P&gt;You'll want to add them one at a time (or a couple when more confident), in groups like &lt;CODE&gt;(?&amp;lt;field1&amp;gt;[^\|]+)\|&lt;/CODE&gt; except the very last one won't have a closing pipe symbol, so you'll end it with &lt;CODE&gt;(?&amp;lt;fieldN&amp;gt;[^\|]+)&lt;/CODE&gt; .  Notice no ending &lt;CODE&gt;\|&lt;/CODE&gt; .&lt;/P&gt;

&lt;P&gt;Le me know if that gets it for you.&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2016 17:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234298#M69626</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-05-07T17:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for complex search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234299#M69627</link>
      <description>&lt;P&gt;Oops, I noticed you have two pipes together.  So I changed all the  &lt;CODE&gt;+&lt;/CODE&gt; (one or more) symbols in the capture groups to &lt;CODE&gt;*&lt;/CODE&gt; (zero or more), like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...| rex field=a_field "^[^\:]+\:(?&amp;lt;field1&amp;gt;[^\|]*)\|(?&amp;lt;field2&amp;gt;[^\|]*)\|(?&amp;lt;field3&amp;gt;[^\|]*)\|(?&amp;lt;field4&amp;gt;[^\|]*)\|(?&amp;lt;field5&amp;gt;[^\|]*)\|(?&amp;lt;field6&amp;gt;[^\|]*)\|(?&amp;lt;field7&amp;gt;[^\|]*)\|(?&amp;lt;field8&amp;gt;[^\|]*)\|(?&amp;lt;field9&amp;gt;[^\|]*)\|(?&amp;lt;field10&amp;gt;[^\|]*)\|(?&amp;lt;field11&amp;gt;[^\|]*)\|(?&amp;lt;field12&amp;gt;[^\|]*)\|(?&amp;lt;field13&amp;gt;[^\|]*)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You'll have to use &lt;EM&gt;your&lt;/EM&gt; fieldname in the place of my "a_field" or just leave that entire little piece off so it uses _raw.  Anyway, that's up to field 13 which is itself a composite field.  The same technique could be used on it too, like &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex field=field13 "(?&amp;lt;code1&amp;gt;\d+)[^\d]+(?&amp;lt;code2&amp;gt;\d+)[^\d]+(?&amp;lt;code3&amp;gt;\d+)[^\d]+(?&amp;lt;code4&amp;gt;\d+)[^\d]+(?&amp;lt;code5&amp;gt;\d+)[^\d]+(?&amp;lt;code6&amp;gt;\d+)[^\d]+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That one looks for repeated "digits, not digits" (i.e. spaces and commas) patterns INSIDE field13, and names them code1, code2...&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2016 17:56:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234299#M69627</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-05-07T17:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for complex search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234300#M69628</link>
      <description>&lt;P&gt;Try the following (you can ignore the top three lines as they are needed to generate demo data):&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Approach one&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| fields - count
| eval _raw = "
Promotion Created, Coupon Settings For PromoCode=121509PromoId=3550966 : 17429150|Gillette|111082|9999999|Save $5.00 on Gillette|Save $5.00 on ONE Gillette Fusion ProShield|2016-05-29T07:00:00Z|2016-07-02T07:00:00Z|2016-07-02T07:00:00Z||811000474001215093500110100|RMS|[047400656048, 047400656055, 047400656062, 047400656079, 047400656109, 047400656116]|[]||RetailerBanners : [Brookshire]
"
| rex field=_raw "PromoCode=(?&amp;lt;PromoCode&amp;gt;\d+)PromoId=(?&amp;lt;PromoId&amp;gt;\d+)\s+:\s+(?&amp;lt;Column1&amp;gt;\d+)\|(?&amp;lt;Column2&amp;gt;[^\|]+)\|(?&amp;lt;Column3&amp;gt;[^\|]+)\|(?&amp;lt;Column4&amp;gt;[^\|]+)\|(?&amp;lt;Column5&amp;gt;[^\|]+)\|(?&amp;lt;Column6&amp;gt;[^\|]+)\|(?&amp;lt;Column7&amp;gt;[^\|]+)\|(?&amp;lt;Column8&amp;gt;[^\|]+)\|(?&amp;lt;Column9&amp;gt;[^\|]+)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output (see picture 1):&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/1321i25683AEB59F6540C/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Explanation: &lt;A href="https://regex101.com/r/sR3pL0/1"&gt;https://regex101.com/r/sR3pL0/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Approach 2&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;You could use split to store all your columns in a multivalue field and access the ones you need very easily with mvindex.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| fields - count
| eval _raw = "
Promotion Created, Coupon Settings For PromoCode=121509PromoId=3550966 : 17429150|Gillette|111082|9999999|Save $5.00 on Gillette|Save $5.00 on ONE Gillette Fusion ProShield|2016-05-29T07:00:00Z|2016-07-02T07:00:00Z|2016-07-02T07:00:00Z||811000474001215093500110100|RMS|[047400656048, 047400656055, 047400656062, 047400656079, 047400656109, 047400656116]|[]||RetailerBanners : [Brookshire]
"
| rex field=_raw "PromoCode=(?&amp;lt;PromoCode&amp;gt;\d+)PromoId=(?&amp;lt;PromoId&amp;gt;\d+)\s+:\s+(?&amp;lt;Columns&amp;gt;.+?)\|\|"
| eval Columns = split(Columns, "|")
| eval Column1 = mvindex(Columns, 0)
| eval Column2 = mvindex(Columns, 1)
......
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Output:&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/1322i939EA030FF94E939/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Hope that helps.&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2016 18:48:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234300#M69628</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-05-07T18:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for complex search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234301#M69629</link>
      <description>&lt;P&gt;Here's a link to the first portion (not the field13 stuff, but before) &lt;A href="https://regex101.com/r/qF4lD2/2"&gt;in regex101.com&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 May 2016 19:21:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234301#M69629</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-05-07T19:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Regex for complex search string</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234302#M69630</link>
      <description>&lt;P&gt;Thanks rich. this was really helpful&lt;/P&gt;</description>
      <pubDate>Sun, 08 May 2016 14:14:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-for-complex-search-string/m-p/234302#M69630</guid>
      <dc:creator>arunsubram</dc:creator>
      <dc:date>2016-05-08T14:14:12Z</dc:date>
    </item>
  </channel>
</rss>

