Backslash in the if statement - LogStash


(Hung Minh Nguyen) #1

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?


(Kabilan) #2

if [\\] in [field1]
{}

try without the parentheses, let me know if that works


(Hung Minh Nguyen) #3

Thanks for your response. this doesnt work


(Hung Minh Nguyen) #4

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

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

}


(system) #5

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