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!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...