Splunk Search

regex global modifiers

alon7786
New Member

Hi,

I trying to execute regex in search command with g (global) m (multi-line) s (single-line).
the regular way (?gms) yields g is unknown flag, so I've tried to convert it to sed mode s/(?ms).../replace/g.
Am I missing something?
Is there another way to achieve it?

Tags (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Instead of the g modifier, use the max_match option. For example:

... | rex max_match=0 "(?ms)(foo)" | ...

will find all instances of 'foo' in _raw.

That said, replacing rex with sed does something very different. What exactly are you trying to accomplish with rex?

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Instead of the g modifier, use the max_match option. For example:

... | rex max_match=0 "(?ms)(foo)" | ...

will find all instances of 'foo' in _raw.

That said, replacing rex with sed does something very different. What exactly are you trying to accomplish with rex?

---
If this reply helps you, Karma would be appreciated.
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...