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!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...