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!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...