Getting Data In

How to remove double quotes from a token using the replace method?

diogenesloazeve
Engager

Hello!

I have the token() whose content is this: 

$support_group_token$=support_group="Service Desk"

 

Is there any way to remove the quotes from the token?
I tried to remove the double quotes using single quotes but the replace didn't work.

|eval my_variable = IF(replace('support_group="Service Desk","\"","")="support_group=Service Desk",1,0)
|table my_variable

MY_VARIABLE.PNG

Has anyone experienced the same problem?

Basically I want to get the result below but the problem is that my token doesn't have the \" between the Service Desk name.

Capture2.PNG

Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust

If you are trying to set a token in XML try

<eval token="my_variable">replace($support_group_token$,"\"","")</eval>

View solution in original post

0 Karma

renjith_nair
Legend

You may use the same solution.. \ is used to escape the quotes.

Please check this

|makeresults |eval field="support_group=\"Service Desk\""
|eval new_field=replace(field,"\"","")

 

 

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

diogenesloazeve
Engager

@renjith_nair Thanks for the answer!

Unfortunately this solution does not work for me because the token already comes to me this way (support_group="Service Desk").
I have to work with the double quotes anyway.

I think the solution is in what character do I have to put before support and after Desk.
Unfortunately trying something like this didn't work for me either:

|makeresults |eval field=\"support_group="Service Desk"\"
0 Karma

renjith_nair
Legend

@diogenesloazeve ,

Here is an example with token. Let me know if this is what you are looking for.

Used $token|s$ to escape the token and replaced 

<form>
  <label>Token Special</label>
  <fieldset submitButton="false">
    <input type="dropdown" token="category">
      <label>Category</label>
      <choice value="support_group=&quot;Service Desk&quot;">SupportGroup</choice>
      <choice value="support_level=&quot;Level1&quot;">SupportLevel</choice>
    </input>
  </fieldset>
  <row>
    <panel>
      <title>Category  : $category$</title>
      <table>
        <search>
          <query>|makeresults|eval category=$category|s$|eval new_category=replace($category|s$,"\"","")</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">none</option>
        <option name="refresh.display">progressbar</option>
      </table>
    </panel>
  </row>
</form>

 

 

---
What goes around comes around. If it helps, hit it with Karma 🙂
0 Karma

diogenesloazeve
Engager

@renjith_nair 
Good hint!
Unfortunately it wouldn't work either because my token is of the multiselect type

<input type="multiselect" token="support_group_token">
      <label>Support Group</label>
      <choice value="*">All</choice>
      <default>*</default>
      <search base="filters_base_search">
        <query>
          | stats count by support_group
        </query>
      </search>
      <fieldForLabel>support_group</fieldForLabel>
      <fieldForValue>support_group</fieldForValue>
      <valuePrefix>support_group="</valuePrefix>
      <valueSuffix>"</valueSuffix>
      <delimiter> OR </delimiter>
</input>
0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

If you are trying to set a token in XML try

<eval token="my_variable">replace($support_group_token$,"\"","")</eval>
0 Karma

diogenesloazeve
Engager

Thank you @ITWhisperer !
This worked perfectly!

0 Karma
Get Updates on the Splunk Community!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...