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!

Data Management Digest – December 2025

Welcome to the December edition of Data Management Digest! As we continue our journey of data innovation, the ...

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...