Use regular expressions to determine whether the content contains #13876
-
I want to use if / else if / else regular expression to determine whether it contains content to add fields. I don't know how to write it. After testing, it can't be realized. Is there a code example? Thank you old code } |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@tiantian34 There are VRL functions for checking if a string matches a regular expression, but there's also a few other string-related functions for checking for if a string contains a substring, which may be beneficial to you given your example:
You can see some examples of using the |
Beta Was this translation helpful? Give feedback.
@tiantian34 There are VRL functions for checking if a string matches a regular expression, but there's also a few other string-related functions for checking for if a string contains a substring, which may be beneficial to you given your example:
contains
will allow you to check to see if a substring is contained within a stringstarts_with
/ends_with
will let you check if a string starts with, or ends with, a specific substringmatch
allows you to check if a string matches a regular expression (andmatch_any
lets you check against multiple regular expressions at the same time)You can see some examples of using the
remap
transform, including writing VRL, in the examples section here: ht…