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!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...