Splunk Search

Python SDK escaping regular expressions in search

askjoe
Engager

I am running searches via the Python SDK and having issues when I include regular expressions as part of the search. How do I escape the regular expression so the search can run as expected?

The search regex causing issues:

..... | regex http.hostname="\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b" | .......

The error:

ExpatError: not well-formed (invalid token): line 5, column 148

Basically I'm looking to match IP

Tags (4)

rafamss
Contributor

Hi askjoe,

Do you need help for this question yet?

[]s
Rafael Martins

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

(view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...