<?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 How to extract two strings from my sample data and concatenate them as one field value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287372#M86974</link>
    <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I'm trying to extract the &lt;STRONG&gt;"1234567/123"&lt;/STRONG&gt; from the string below, but I'd like the final output to be &lt;STRONG&gt;"1234567123"&lt;/STRONG&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"/for/1234567/123/AB1+2BC
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did come up with the following &lt;CODE&gt;"\/for\/(?&amp;lt;refno&amp;gt;[^\/]+)\/(?&amp;lt;refno2&amp;gt;[^\/]+)\/&lt;/CODE&gt;, but I wasn't sure about how to join the "refno" and refno2". I also wasn't sure if there was a more elegant way of doing this.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone could possibly look at this please and offer some guidance on how I may go about achieving this.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Mon, 11 Apr 2016 14:38:49 GMT</pubDate>
    <dc:creator>IRHM73</dc:creator>
    <dc:date>2016-04-11T14:38:49Z</dc:date>
    <item>
      <title>How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287372#M86974</link>
      <description>&lt;P&gt;Hi, &lt;/P&gt;

&lt;P&gt;I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I'm trying to extract the &lt;STRONG&gt;"1234567/123"&lt;/STRONG&gt; from the string below, but I'd like the final output to be &lt;STRONG&gt;"1234567123"&lt;/STRONG&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"/for/1234567/123/AB1+2BC
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I did come up with the following &lt;CODE&gt;"\/for\/(?&amp;lt;refno&amp;gt;[^\/]+)\/(?&amp;lt;refno2&amp;gt;[^\/]+)\/&lt;/CODE&gt;, but I wasn't sure about how to join the "refno" and refno2". I also wasn't sure if there was a more elegant way of doing this.&lt;/P&gt;

&lt;P&gt;I just wondered whether someone could possibly look at this please and offer some guidance on how I may go about achieving this.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 14:38:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287372#M86974</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-04-11T14:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287373#M86975</link>
      <description>&lt;P&gt;If you're doing this in a search query you can join the fields using &lt;CODE&gt;eval&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex "\/for\/(?&amp;lt;refno&amp;gt;[^\/]+)\/(?&amp;lt;refno2&amp;gt;[^\/]+)\/" | eval refno=refno . refno2 | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2016 15:05:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287373#M86975</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-04-11T15:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287374#M86976</link>
      <description>&lt;P&gt;Try this (without the first two lines I've used for testing of course):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count
| eval _raw = "/for/1234567/123/AB1+2BC"
| rex max_match=0 "(?&amp;lt;mynum&amp;gt;\d+)\/"
| eval mynum = mvjoin(mynum,"")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2016 15:08:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287374#M86976</guid>
      <dc:creator>javiergn</dc:creator>
      <dc:date>2016-04-11T15:08:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287375#M86977</link>
      <description>&lt;P&gt;If you're extracting this refno from an existing field (say source), then try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | eval refno=replace(source,"\/for\/([^\/]+)\/([^\/]+)\/","\1\2")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 11 Apr 2016 15:09:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287375#M86977</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-04-11T15:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287376#M86978</link>
      <description>&lt;P&gt;just use | STRCAT refno refno2 NewRef | table NewRef&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 18:50:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287376#M86978</guid>
      <dc:creator>nravichandran</dc:creator>
      <dc:date>2016-04-11T18:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287377#M86979</link>
      <description>&lt;P&gt;Assuming you have this string in a field called &lt;CODE&gt;reference&lt;/CODE&gt;, which can be simulated like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|stats count|eval reference = "/for/1234567/123/AB1+2BC"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then you can do it like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval refno=reference
| rex field=refno mode=sed "s%/[^/]+/([^/]+)/([^/]+).*%\1\2%"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Apr 2016 05:39:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287377#M86979</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-04-12T05:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287378#M86980</link>
      <description>&lt;P&gt;Hi @javiergn, thank you for coming back to me with this.&lt;/P&gt;

&lt;P&gt;I was able to extract the data which was great, but when it came the join, it repeated the number in the field.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 05:56:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287378#M86980</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-04-12T05:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287379#M86981</link>
      <description>&lt;P&gt;Hi @somesoni2, thank you for coming back to me with this.&lt;/P&gt;

&lt;P&gt;Unfortunately I wasn't able to use this because I needed to extract the information from the raw data. When I used '_raw' as the replacement to 'source', this didn't extract the information, so I assumed the field where the regex is extracting the data from must be a definitive field.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 05:59:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287379#M86981</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-04-12T05:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287380#M86982</link>
      <description>&lt;P&gt;Hi @richgalloway, thank you for taking the time to reply and for the solution which works great. Just pipped to the post by @nravichandran&lt;/P&gt;

&lt;P&gt;Kind Regads&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 06:00:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287380#M86982</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-04-12T06:00:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract two strings from my sample data and concatenate them as one field value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287381#M86983</link>
      <description>&lt;P&gt;Hi, thank you for taking the time to reply to my post.&lt;/P&gt;

&lt;P&gt;The solution is great.&lt;/P&gt;

&lt;P&gt;Kind Regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Tue, 12 Apr 2016 06:01:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-two-strings-from-my-sample-data-and-concatenate/m-p/287381#M86983</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2016-04-12T06:01:17Z</dc:date>
    </item>
  </channel>
</rss>

