<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to replace every backslash in an input form token with a double backslash in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345031#M22454</link>
    <description>&lt;P&gt;Progetto="$progetto$|s", with an initial value of "&lt;EM&gt;" for progetto field gives no results.&lt;BR /&gt;
Also tried with value "\NAS&lt;/EM&gt;" and still get no results.&lt;BR /&gt;
(Obviously there are a lot of records in the index that have "\NAS" at the beginning of the field).&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2017 12:38:45 GMT</pubDate>
    <dc:creator>cafissimo</dc:creator>
    <dc:date>2017-09-21T12:38:45Z</dc:date>
    <item>
      <title>How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345029#M22452</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;
please I would like to know how I can replace a single "\" backslash with a double "\" backslash in a form input (simple xml) before submitting it.&lt;/P&gt;

&lt;P&gt;I have tried with this code, but it does not work with splunk 6.5.x&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;    &amp;lt;input type="text" token="progetto"&amp;gt;
      &amp;lt;label&amp;gt;Progetto (raddoppiare i "\")&amp;lt;/label&amp;gt;
      &amp;lt;default&amp;gt;*&amp;lt;/default&amp;gt;
      &amp;lt;initialValue&amp;gt;*&amp;lt;/initialValue&amp;gt;
      &amp;lt;change&amp;gt;
         &amp;lt;eval token="progetto"&amp;gt;replace('progetto',"\\\","\\\\\\")&amp;lt;/eval&amp;gt;     
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 12:07:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345029#M22452</guid>
      <dc:creator>cafissimo</dc:creator>
      <dc:date>2017-09-21T12:07:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345030#M22453</link>
      <description>&lt;P&gt;have you tried using &lt;CODE&gt;field=$progetto|s$&lt;/CODE&gt; in your search instead of trying to escape the backslash in your input? the &lt;CODE&gt;|s&lt;/CODE&gt; will enclose the token in quotes and that might work.&lt;/P&gt;

&lt;P&gt;also, i did test your input on 6.6.1, and it seems to work there if you plan on upgrading anytime soon.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 12:16:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345030#M22453</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-09-21T12:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345031#M22454</link>
      <description>&lt;P&gt;Progetto="$progetto$|s", with an initial value of "&lt;EM&gt;" for progetto field gives no results.&lt;BR /&gt;
Also tried with value "\NAS&lt;/EM&gt;" and still get no results.&lt;BR /&gt;
(Obviously there are a lot of records in the index that have "\NAS" at the beginning of the field).&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 12:38:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345031#M22454</guid>
      <dc:creator>cafissimo</dc:creator>
      <dc:date>2017-09-21T12:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345032#M22455</link>
      <description>&lt;P&gt;Hi @cafissimo&lt;/P&gt;

&lt;P&gt;As paradox as it may seem - try the following code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;fieldset&amp;gt;
  &amp;lt;input type="text" token="test1"&amp;gt;
    &amp;lt;label&amp;gt;field1&amp;lt;/label&amp;gt;
    &amp;lt;change&amp;gt;
      &amp;lt;eval token="test2"&amp;gt;replace('test1',"\\\\","\\\\")&amp;lt;/eval&amp;gt;
    &amp;lt;/change&amp;gt;
  &amp;lt;/input&amp;gt;
&amp;lt;/fieldset&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This renders the correct results for me. &lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 12:44:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345032#M22455</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2017-09-21T12:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345033#M22456</link>
      <description>&lt;P&gt;@DMohn: please, could you please provide me the complete form you used? Mine hangs on "waiting for input", even if I put test2 in my search query.&lt;BR /&gt;
Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 13:29:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345033#M22456</guid>
      <dc:creator>cafissimo</dc:creator>
      <dc:date>2017-09-21T13:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345034#M22457</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;test1&amp;lt;/label&amp;gt;
  &amp;lt;fieldset&amp;gt;
    &amp;lt;input type="text" token="test1"&amp;gt;
      &amp;lt;label&amp;gt;field1&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="test2"&amp;gt;replace('test1',"\\\\","\\\\")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;html&amp;gt;
      &amp;lt;p&amp;gt;Value1: $test1$&amp;lt;/p&amp;gt;
      &amp;lt;p&amp;gt;Value2: $test2$&amp;lt;/p&amp;gt;
    &amp;lt;/html&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 13:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345034#M22457</guid>
      <dc:creator>DMohn</dc:creator>
      <dc:date>2017-09-21T13:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345035#M22458</link>
      <description>&lt;P&gt;I am sorry, but it works in a weird way.&lt;BR /&gt;
At first run of the form, if I put "\" in field1 nothing happens and field2 is shown as "$field2$".&lt;BR /&gt;
If I add another "\" in field1 ("\") and submit again, the field2 value appears as "\\".&lt;BR /&gt;
By the way, what I need is to repeat each "\" character.&lt;BR /&gt;
For example:&lt;BR /&gt;
\NAS\disc1\disc2 should become "\\NAS\disc1\disc2"&lt;BR /&gt;
Maybe I should use javascript?&lt;/P&gt;

&lt;P&gt;I am running splunk 6.5.3&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2017 14:04:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345035#M22458</guid>
      <dc:creator>cafissimo</dc:creator>
      <dc:date>2017-09-21T14:04:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345036#M22459</link>
      <description>&lt;P&gt;I have found out a way to get what I want: it's done with custom JS code.&lt;/P&gt;

&lt;P&gt;This is the form:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form script="token_modify_mae.js"&amp;gt;
   &amp;lt;label&amp;gt;test1&amp;lt;/label&amp;gt;
   &amp;lt;fieldset&amp;gt;
     &amp;lt;input type="text" token="mytoken"&amp;gt;
       &amp;lt;label&amp;gt;field1&amp;lt;/label&amp;gt;
     &amp;lt;/input&amp;gt;
   &amp;lt;/fieldset&amp;gt;
   &amp;lt;row&amp;gt;
     &amp;lt;html&amp;gt;
       &amp;lt;p&amp;gt;Value1: $mytoken$&amp;lt;/p&amp;gt;
       &amp;lt;p&amp;gt;Value2: $mymodtoken$&amp;lt;/p&amp;gt;
     &amp;lt;/html&amp;gt;
   &amp;lt;/row&amp;gt;
 &amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and this is the JS code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    "splunkjs/mvc",
    "splunkjs/mvc/simplexml/ready!"
], function(mvc) {
var defaultTokenModel = mvc.Components.get("default");
defaultTokenModel.on("change:mytoken", function(formQuery, mytoken) {
            alert("change it!");
            var tokenValue = defaultTokenModel.get("mytoken");
            newtoken = tokenValue.replace(/\\/g, "\\\\");
            defaultTokenModel.set('mymodtoken', newtoken);
        });
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 21 Sep 2017 21:51:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345036#M22459</guid>
      <dc:creator>cafissimo</dc:creator>
      <dc:date>2017-09-21T21:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace every backslash in an input form token with a double backslash</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345037#M22460</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&amp;lt;form&amp;gt;
  &amp;lt;label&amp;gt;test1&amp;lt;/label&amp;gt;
  &amp;lt;fieldset&amp;gt;
    &amp;lt;input type="text" token="test1" searchWhenChanged="true"&amp;gt;
      &amp;lt;label&amp;gt;field1&amp;lt;/label&amp;gt;
      &amp;lt;change&amp;gt;
        &amp;lt;eval token="test2"&amp;gt;replace($form.test1$,"\\\\","\\\\")&amp;lt;/eval&amp;gt;
      &amp;lt;/change&amp;gt;
    &amp;lt;/input&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;row&amp;gt;
    &amp;lt;panel&amp;gt;
      &amp;lt;html&amp;gt;
       &amp;lt;p&amp;gt;Value1: $test1$&amp;lt;/p&amp;gt;
       &amp;lt;p&amp;gt;Value2: $test2$&amp;lt;/p&amp;gt;
     &amp;lt;/html&amp;gt;
    &amp;lt;/panel&amp;gt;
  &amp;lt;/row&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Changing 'test1' -&amp;gt; $form.test1$ seems to fix the issue cafissimo was having.  I also think the searchWhenChanged might also be key to making this all work.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Oct 2019 17:41:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-to-replace-every-backslash-in-an-input-form-token-with-a/m-p/345037#M22460</guid>
      <dc:creator>bekirk</dc:creator>
      <dc:date>2019-10-25T17:41:58Z</dc:date>
    </item>
  </channel>
</rss>

