Splunk Search

The "replace" function does not work well in the element of EventHandler.

yutaka1005
Builder
  <fieldset submitButton="false" autoRun="false">
    <input type="text" token="text" searchWhenChanged="true">
      <label>field1</label>
      <change>
        <eval token="arg">replace($text$,"^(..).(..)$","\1:\2")</eval>
      </change>
      <default></default>
    </input>
  </fieldset>

For example, in the above setting, if I put aa-aa in the text input, the result aa:aa should be substituted in the token arg, but only the value : is substituted.

Should I do something like escape etc?

0 Karma
1 Solution

vnravikumar
Champion

Hi

Try this

<form>
    <fieldset submitButton="false" autoRun="false">
     <input type="text" token="text" searchWhenChanged="true">
       <label>field1</label>
       <change>
         <eval token="form.arg">replace($text$,"(\w)-(\w)","\1:\2")</eval>
       </change>
       <default></default>
     </input>
       <input type="text" token="arg" searchWhenChanged="true"/>
   </fieldset>
</form>

View solution in original post

0 Karma

vnravikumar
Champion

Hi

Try this

<form>
    <fieldset submitButton="false" autoRun="false">
     <input type="text" token="text" searchWhenChanged="true">
       <label>field1</label>
       <change>
         <eval token="form.arg">replace($text$,"(\w)-(\w)","\1:\2")</eval>
       </change>
       <default></default>
     </input>
       <input type="text" token="arg" searchWhenChanged="true"/>
   </fieldset>
</form>
0 Karma

yutaka1005
Builder

Thank you for answer!

I can solve it by this solution.
But I can't do by below settings. It's weird...

<eval token="form.arg">replace($text$,"(\w{2})-(\w{2})","\1:\2")</eval>
0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

Splunk is officially part of Cisco

Revolutionizing how our customers build resilience across their entire digital footprint.   Splunk ...

Splunk APM & RUM | Planned Maintenance March 26 - March 28, 2024

There will be planned maintenance for Splunk APM and RUM between March 26, 2024 and March 28, 2024 as ...