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!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...