<?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: classic xml - token eval using replace function not working in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755327#M59262</link>
    <description>&lt;P&gt;Different flavours of regex use different ways to reference captured values - it looks like Splunk may be using different flavours between SPL and token evals. Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "(\\w*)\\|(\\w*)", "$2")&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;</description>
    <pubDate>Sat, 08 Nov 2025 08:32:18 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2025-11-08T08:32:18Z</dc:date>
    <item>
      <title>classic xml - token eval using replace function not working</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755325#M59261</link>
      <description>&lt;P&gt;&lt;BR /&gt;So I've been turning myself inside out trying to figure this one out and cannot...&lt;/P&gt;&lt;P&gt;In search this works fine, 'test' evaluates to "default"&lt;BR /&gt;&lt;BR /&gt;| makeresults&lt;BR /&gt;| eval value = "users|default"&lt;BR /&gt;| eval test = replace(value, "(\w*)\|(\w*)", "\2")&lt;BR /&gt;&lt;BR /&gt;Trying to make this work as a token eval however is proving difficult. I am trying to do this:&lt;BR /&gt;(where&amp;nbsp;&amp;lt;set token="form.chg_focus"&amp;gt;users|default&amp;lt;/set&amp;gt; is defined elsewhere to trigger a change for the input)&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;input type="text" token="chg_focus" depends="$HIDDEN$"&amp;gt;
  &amp;lt;change&amp;gt;
    &amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "(\w*)\|(\w*)", "\2")&amp;lt;/eval&amp;gt;
  &amp;lt;/change&amp;gt;
&amp;lt;/input&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;The above is a simplified version of the input I am trying to implement which involves multiple token sets and evals.&lt;BR /&gt;&lt;BR /&gt;I figured out that I needed to double up the instances of \ in the regex expression , so for example this works (i.e. I get $nav_chart_mode$=default)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "\\w*\\|", "")&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;So does this&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "\\w*\\|\\w*", "default")&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;However I cannot seem to get this to work - all I get is&amp;nbsp;&lt;SPAN&gt;$nav_chart_mode$="" (i.e. blank string).&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "(\\w*)\\|(\\w*)", "\2")&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&lt;BR /&gt;Using "\\2" results in&amp;nbsp;$nav_chart_mode$=\2, so that isn't the answer.&lt;BR /&gt;&lt;BR /&gt;I also tried using \( and \), i.e. "\(\\w*\)\\|\(\\w*\)", and no joy there - also results in $nav_chart_mode$="".&lt;BR /&gt;&lt;BR /&gt;I also tried using double (( and )), also not helpful... (and not logical, but I was getting desperate &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;)&lt;BR /&gt;&lt;BR /&gt;I am hoping someone out there can help me understand what I am not understanding...&lt;BR /&gt;&lt;BR /&gt;Cheers&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Nov 2025 03:10:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755325#M59261</guid>
      <dc:creator>_guy</dc:creator>
      <dc:date>2025-11-08T03:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: classic xml - token eval using replace function not working</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755327#M59262</link>
      <description>&lt;P&gt;Different flavours of regex use different ways to reference captured values - it looks like Splunk may be using different flavours between SPL and token evals. Try this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "(\\w*)\\|(\\w*)", "$2")&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 08 Nov 2025 08:32:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755327#M59262</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2025-11-08T08:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: classic xml - token eval using replace function not working</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755328#M59263</link>
      <description>&lt;P&gt;You tried doubling the escape characters in the pattern, but did you try it in the replacement?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;eval token="nav_chart_mode"&amp;gt;replace($value$, "(\\w*)\\|(\\w*)", "\\2")&amp;lt;/eval&amp;gt;&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 08 Nov 2025 12:42:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755328#M59263</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2025-11-08T12:42:40Z</dc:date>
    </item>
    <item>
      <title>Re: classic xml - token eval using replace function not working</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755362#M59266</link>
      <description>&lt;P&gt;Awesome, thank you! I felt it had to be possible with the right tweak, and you nailed it &lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Nov 2025 13:31:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755362#M59266</guid>
      <dc:creator>_guy</dc:creator>
      <dc:date>2025-11-10T13:31:37Z</dc:date>
    </item>
    <item>
      <title>Re: classic xml - token eval using replace function not working</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755363#M59267</link>
      <description>&lt;P&gt;Thanks for the suggestion &lt;SPAN&gt;richgalloway&lt;/SPAN&gt;, but yes, I tried that and it resulted in this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;nav_chart_mode="\2"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Nov 2025 13:33:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/classic-xml-token-eval-using-replace-function-not-working/m-p/755363#M59267</guid>
      <dc:creator>_guy</dc:creator>
      <dc:date>2025-11-10T13:33:58Z</dc:date>
    </item>
  </channel>
</rss>

