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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Unlocking Unified Insights: New Gigamon Federated Search App for Splunk

In today’s data-heavy environment, organizations are caught in a data distribution dilemma. As data volumes ...

GA: New Data Management App in Splunk Platform

Streamlining Data Management: Introducing a unified experience in Splunk Managing data at scale shouldn’t feel ...

Announcing Modern Navigation: A New Era of Splunk User Experience

We are excited to introduce the Modern Navigation feature in the Splunk Platform, available to both cloud and ...