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!

Detecting Remote Code Executions With the Splunk Threat Research Team

WATCH NOWRemote code execution (RCE) vulnerabilities pose a significant risk to organizations. If exploited, ...

Enter the Splunk Community Dashboard Challenge for Your Chance to Win!

The Splunk Community Dashboard Challenge is underway! This is your chance to showcase your skills in creating ...

.conf24 | Session Scheduler is Live!!

.conf24 is happening June 11 - 14 in Las Vegas, and we are thrilled to announce that the conference catalog ...