Backslash in the if statement - LogStash

Hi, I would like to know how to write an if statement with the condition of a (backslash) being in the string like below:

if ( \backslash\ in [field1] ) {
Do_something {}
}

I have tried:

  • if ( "\" in [field1] ) {}
  • if ( [\] in [field1] ) {}

but none of it works. I feel like the second option is very close to what works but I dont know the exact syntax. Could somebody help?

if [\\] in [field1]
{}

try without the parentheses, let me know if that works

Thanks for your response. this doesnt work

so eventually, I found the solution with regex, probably not the perfect solution but it works at the moment for me:

if [field1] =~ /^.+\.+$/ {

}

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.