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!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...