Splunk Enterprise

eval Token Regex, Need to remove open & close brackets

AnilPujar
Path Finder

I need help removing these open & closed brackets in the token, please see below the dashboard code FYI

 

 

<form>
  <label>token eval drilldown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="manager" searchWhenChanged="true">
      <label>Account Managers</label>
      <choice value="*">All</choice>
      <choice value="123&quot;,&quot;456&quot;,&quot;789&quot;,&quot;431C&quot;,&quot;343">XYZ</choice>
      <choice value="786&quot;,&quot;274&quot;,&quot;245&quot;,&quot;237&quot;,&quot;2523&quot;,&quot;245&quot;,&quot;257">ABC</choice>
      <choice value="463&quot;,&quot;234&quot;,&quot;234&quot;,&quot;3543">DEF</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>| search u_user_type IN (</prefix>
      <suffix>)</suffix>
      <!--<valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>-->
      <change>
        <condition>
          <eval token="tok_manager">replace($manager$,"(.\| search u_user_type IN \()","")</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$manager$</p>
        <p>$tok_manager$   &lt;-- i need to remove these open &amp; close brackets</p>
      </html>
    </panel>
  </row>
</form>

 

 

Labels (2)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

You need an extra backslash on the escapes

<form version="1.0.0">
  <label>token eval drilldown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="manager" searchWhenChanged="true">
      <label>Account Managers</label>
      <choice value="*">All</choice>
      <choice value="123&quot;,&quot;456&quot;,&quot;789&quot;,&quot;431C&quot;,&quot;343">XYZ</choice>
      <choice value="786&quot;,&quot;274&quot;,&quot;245&quot;,&quot;237&quot;,&quot;2523&quot;,&quot;245&quot;,&quot;257">ABC</choice>
      <choice value="463&quot;,&quot;234&quot;,&quot;234&quot;,&quot;3543">DEF</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>| search u_user_type IN (</prefix>
      <suffix>)</suffix>
      <!--<valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>-->
      <change>
        <condition>
          <eval token="tok_manager">replace(replace($manager$,"(\\| search u_user_type IN \\()",""),"(\\))","")</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$manager$</p>
        <p>$tok_manager$   &lt;-- i need to remove these open &amp; close brackets</p>
      </html>
    </panel>
  </row>
</form>

View solution in original post

AnilPujar
Path Finder

Thanks, @ITWhisperer 

It worked

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

You need an extra backslash on the escapes

<form version="1.0.0">
  <label>token eval drilldown</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="manager" searchWhenChanged="true">
      <label>Account Managers</label>
      <choice value="*">All</choice>
      <choice value="123&quot;,&quot;456&quot;,&quot;789&quot;,&quot;431C&quot;,&quot;343">XYZ</choice>
      <choice value="786&quot;,&quot;274&quot;,&quot;245&quot;,&quot;237&quot;,&quot;2523&quot;,&quot;245&quot;,&quot;257">ABC</choice>
      <choice value="463&quot;,&quot;234&quot;,&quot;234&quot;,&quot;3543">DEF</choice>
      <default>*</default>
      <initialValue>*</initialValue>
      <prefix>| search u_user_type IN (</prefix>
      <suffix>)</suffix>
      <!--<valuePrefix>"</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter>, </delimiter>-->
      <change>
        <condition>
          <eval token="tok_manager">replace(replace($manager$,"(\\| search u_user_type IN \\()",""),"(\\))","")</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <html>
        <p>$manager$</p>
        <p>$tok_manager$   &lt;-- i need to remove these open &amp; close brackets</p>
      </html>
    </panel>
  </row>
</form>
Get Updates on the Splunk Community!

Index This | Why do they call it hyper text?

November 2023 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

State of Splunk Careers 2023: Career Resilience and the Continued Value of Splunk

For the past three years, Splunk has partnered with Enterprise Strategy Group to conduct a survey that gauges ...

The Great Resilience Quest: 9th Leaderboard Update

The ninth leaderboard update (11.9-11.22) for The Great Resilience Quest is out &gt;&gt; Kudos to all the ...