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

Labels (1)
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!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...