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 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...