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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...