开发者

KRL convert string to lowercase in pre block

开发者 https://www.devze.com 2023-01-29 08:08 出处:网络
Question Is there a way in the pre block of a rule to convert a string to all lowe开发者_StackOverflowr case?

Question

Is there a way in the pre block of a rule to convert a string to all lowe开发者_StackOverflowr case?

Background

I have a regular expression that returns parts of a string and sometimes they start with an uppercase and sometimes not. Because I want to use the result from the regex as a key in a hashmap I need the case to always be consistent.


Yup! lc() is your friend. Rule example:

rule example {
 select when somedomain someevent
  pre {
    x = "FOO";
    y = x.lc();
  }
  noop();
}

Docs Link: http://docs.kynetx.com/docs/Lc

0

精彩评论

暂无评论...
验证码 换一张
取 消