<?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: REX parenthesis and end of line in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577292#M201185</link>
    <description>&lt;P&gt;By the way - I have also tried to extract the value using Field Extractor but then I don't get matches for ALL possible values, I have tried many times using different samples etc. and the best way thus far is extracting two fields using two different regex compilations assembled by the SPLUNK Field Extractor guide itself. But listing them forces me to return duplicates and sometimes a false value as it results in a prev. value found earlier (not at the end) in the line.&lt;/P&gt;</description>
    <pubDate>Fri, 03 Dec 2021 22:30:14 GMT</pubDate>
    <dc:creator>martinhelgegren</dc:creator>
    <dc:date>2021-12-03T22:30:14Z</dc:date>
    <item>
      <title>REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577280#M201174</link>
      <description>&lt;P&gt;Hi! Been struggling a lot with a pretty simple problem but my SPLUNK REX skills are insufficient for the task. I want to match and list ANY value containing both letters, digits and characters between parenthesis at the end of line/end of string - examples:&lt;BR /&gt;&lt;BR /&gt;bla bla bla (My Value0/0)&lt;BR /&gt;bla bla blb (My OtherValue0/1)&lt;BR /&gt;bla blb blc (My thirdValue0/0/0/0)&lt;/P&gt;&lt;P&gt;As you can see - the text BEFORE the ending value inside parenthesis can be what ever. There can also be MULTIPLE similar values also within parenthesis along the string but I ONLY want to match the one at end of line ($). The match must be every letter, space, number or typically "/" characters between the parenthesis.&lt;/P&gt;&lt;P&gt;Using other regex dev tools I get a fairly decent result with a simple string like this:&lt;BR /&gt;&lt;BR /&gt;\(.*\)$&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;\(&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;matches the character&amp;nbsp;&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&amp;nbsp;with index&amp;nbsp;&lt;SPAN class=""&gt;4010&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN class=""&gt;2816&lt;/SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;SPAN class=""&gt;508&lt;/SPAN&gt;) literally (case sensitive)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class=""&gt;matches any character (except for line terminators)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;*&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;matches the previous token between&amp;nbsp;&lt;SPAN class=""&gt;zero&lt;/SPAN&gt;&amp;nbsp;and&amp;nbsp;&lt;SPAN class=""&gt;unlimited&lt;/SPAN&gt;&amp;nbsp;times,&amp;nbsp;as many times as possible, giving back as needed&amp;nbsp;&lt;SPAN class=""&gt;(greedy)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;\)&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;matches the character&amp;nbsp;&lt;SPAN class=""&gt;)&lt;/SPAN&gt;&amp;nbsp;with index&amp;nbsp;&lt;SPAN class=""&gt;4110&lt;/SPAN&gt;&amp;nbsp;(&lt;SPAN class=""&gt;2916&lt;/SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;SPAN class=""&gt;518&lt;/SPAN&gt;) literally (case sensitive)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;$&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;asserts position at the end of a line&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I also have used variants of this and they all end up working very well in regex testers and dev tools and also in LINUX (when pasting the entire table of messages into a file and applying them. But not in SPLUNK - I believe there is a big coin drop along my SPLUNK use path when everything will make sense to me, unfortunately not there yet. Please help me out!&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 03 Dec 2021 21:18:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577280#M201174</guid>
      <dc:creator>martinhelgegren</dc:creator>
      <dc:date>2021-12-03T21:18:12Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577282#M201176</link>
      <description>&lt;LI-CODE lang="markup"&gt;| rex "\((?&amp;lt;result&amp;gt;[^\)]+)\)$"&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 21:34:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577282#M201176</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-12-03T21:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577285#M201178</link>
      <description>&lt;P&gt;Sorry - no luck. Also the&amp;nbsp;[^\)]+) included (basically added to what I already tried:&lt;BR /&gt;&lt;BR /&gt;| rex "\((?&amp;lt;result&amp;gt;)\)$"&lt;/P&gt;&lt;P&gt;...where \( is literal (?&amp;lt;result&amp;gt;) is my intended result match followed by ) as literal $ at end of line/string. What would be the intention of matching ^\) one or more times? Here's a more true sample line and I want the bold value between parenthesis (with or without including them - doesn't matter):&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN class=""&gt;New&lt;/SPAN&gt; &lt;SPAN class=""&gt;selection&lt;/SPAN&gt; &lt;SPAN class=""&gt;for&lt;/SPAN&gt; &lt;SPAN class=""&gt;selection&lt;/SPAN&gt; &lt;SPAN class=""&gt;point&lt;/SPAN&gt; &lt;SPAN class=""&gt;1588-SEL:&lt;/SPAN&gt; &lt;SPAN class=""&gt;1&lt;/SPAN&gt; &lt;SPAN class=""&gt;inputs&lt;/SPAN&gt; &lt;SPAN class=""&gt;selected:&lt;/SPAN&gt; &lt;SPAN class=""&gt;input&lt;/SPAN&gt; &lt;SPAN class=""&gt;from&lt;/SPAN&gt; &lt;SPAN class=""&gt;Selection&lt;/SPAN&gt; &lt;SPAN class=""&gt;0/0/CPU0-ETH_RXMUX&lt;/SPAN&gt;(&lt;SPAN class=""&gt;1&lt;/SPAN&gt;) (&lt;STRONG&gt;&lt;SPAN class=""&gt;Line&lt;/SPAN&gt; &lt;SPAN class=""&gt;GigabitEthernet0/0/0/0&lt;/SPAN&gt;&lt;/STRONG&gt;)&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 21:47:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577285#M201178</guid>
      <dc:creator>martinhelgegren</dc:creator>
      <dc:date>2021-12-03T21:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577286#M201179</link>
      <description>&lt;P&gt;Here is the regex working in regex101.com&amp;nbsp;&lt;A href="https://regex101.com/r/LInaT6/1" target="_self"&gt;https://regex101.com/r/LInaT6/1&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 21:51:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577286#M201179</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-12-03T21:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577287#M201180</link>
      <description>&lt;P&gt;And a runanywhere example with your data&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="New selection for selection point 1588-SEL: 1 inputs selected: input from Selection 0/0/CPU0-ETH_RXMUX(1) (Line GigabitEthernet0/0/0/0)"
| rex "\((?&amp;lt;result&amp;gt;[^\)]+)\)$"&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 03 Dec 2021 21:54:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577287#M201180</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-12-03T21:54:35Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577291#M201184</link>
      <description>&lt;P&gt;Yes, both regex101.com and the makeresults info you pasted does indeed work in my SPLUNK system. But appending:&lt;BR /&gt;&lt;BR /&gt;| rex "\((?&amp;lt;result&amp;gt;[^\)]+)\)$"&lt;/P&gt;&lt;P&gt;...to my search and trying to print the actual results are returning "result=null" according to SPLUNK. I get the timestamps right when adding "_time" to my printing attempts. Maybe the REX is indeed valid but I'm simply using wrong method in trying to print it.&lt;/P&gt;&lt;P&gt;After I have a matched REX result I want to print a Field (already extracted - in this case a &lt;EM&gt;hostname&lt;/EM&gt;), &lt;EM&gt;time&lt;/EM&gt;&amp;nbsp;(timestamp of the entered log message) and the actual REX result (eg. &lt;EM&gt;Line GigabitEthernet0/0/0/0&lt;/EM&gt;) on a single row/line. Any help on how to table or chart or anything else I can use to perform it?&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 22:26:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577291#M201184</guid>
      <dc:creator>martinhelgegren</dc:creator>
      <dc:date>2021-12-03T22:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577292#M201185</link>
      <description>&lt;P&gt;By the way - I have also tried to extract the value using Field Extractor but then I don't get matches for ALL possible values, I have tried many times using different samples etc. and the best way thus far is extracting two fields using two different regex compilations assembled by the SPLUNK Field Extractor guide itself. But listing them forces me to return duplicates and sometimes a false value as it results in a prev. value found earlier (not at the end) in the line.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Dec 2021 22:30:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577292#M201185</guid>
      <dc:creator>martinhelgegren</dc:creator>
      <dc:date>2021-12-03T22:30:14Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577298#M201188</link>
      <description>&lt;P&gt;Your regex could be impacted by things like hidden carriage returns, newlines, and space at end of line that may not be obvious in the UI.&amp;nbsp;Sometimes you have to throw stuff against the wall to figure out where the issue lies.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try these:&lt;/P&gt;&lt;P&gt;- Multivalue Match&lt;BR /&gt;| rex max_match=100 "(?ms)\((?&amp;lt;result_1&amp;gt;[^\)]+)\)"&lt;BR /&gt;| eval result_2=mvindex(result_1, -1)&lt;/P&gt;&lt;P&gt;- Using Split&lt;BR /&gt;| eval result_1=split(_raw,"(")&lt;BR /&gt;| eval result_2=mvindex(result_1, -1)&lt;BR /&gt;| rex field=result_2 mode=sed "s/\)(\s+)?//g"&lt;/P&gt;&lt;P&gt;- Sanitize the data (trim end)&lt;BR /&gt;| rex field=_raw mode=sed "s/^[\r\n]+//g"&lt;BR /&gt;| eval _raw=RTRIM(_raw)&lt;BR /&gt;| rex"\((?&amp;lt;result_1&amp;gt;[^\)]+)\)$"&lt;/P&gt;&lt;P&gt;- Ignore possible spaces at the end of the string&lt;BR /&gt;| rex"\((?&amp;lt;result_1&amp;gt;[^\)]+)\)\s+?$"&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 00:54:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577298#M201188</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2021-12-04T00:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: REX parenthesis and end of line</title>
      <link>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577319#M201195</link>
      <description>&lt;P&gt;(re-write my reply to solution)&lt;/P&gt;&lt;P&gt;Bingo! It turns out all but Multivalue Match works like a charm and the explanation should lie in whitespaces in the strings. The rex string needs to look like this:&lt;BR /&gt;&lt;BR /&gt;| rex"\((?&amp;lt;result&amp;gt;[^\)]+)\)\s+?$"&lt;/P&gt;&lt;P&gt;I completed the search with a simple table:&lt;/P&gt;&lt;P&gt;| table host,time,result&lt;/P&gt;&lt;P&gt;Some day I too shall understand why some fields or predefined values needs a prepended underscore...like "_time" (while "host" does not...)&lt;BR /&gt;&lt;BR /&gt;Thank you all for contributing! You are a part of the drive force!&lt;/P&gt;</description>
      <pubDate>Sat, 04 Dec 2021 08:05:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/REX-parenthesis-and-end-of-line/m-p/577319#M201195</guid>
      <dc:creator>martinhelgegren</dc:creator>
      <dc:date>2021-12-04T08:05:58Z</dc:date>
    </item>
  </channel>
</rss>

