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!

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 ...