Splunk Search

Rexgex Non-capturing group - still capturing?

tb5821
Communicator
rex field=title "(?titleNEW(.*?)(?:-))"

I have this rex command above but it still outputs the dash at the end which is in a non-capturing group- any help?

Labels (1)
Tags (2)
0 Karma
1 Solution

tb5821
Communicator

Figured this out - by changing where the new field name paranthesie was...

rex field=title "(?<titleNEW>(.*?))(?:-)"

View solution in original post

tb5821
Communicator

Figured this out - by changing where the new field name paranthesie was...

rex field=title "(?<titleNEW>(.*?))(?:-)"

jotne
Builder

Not sure if you have an optimal regex.  Why do you make a non capturing group of "-" and why a capture group in the named group?  This is some better:

rex field=title "(?<titleNEW>.*?):-"

 Even better, do not use * in regex when its not needed.  Do a search until you find some that its not included, like this:

rex field=title "(?<titleNEW>[^-]+)"

 

0 Karma
Get Updates on the Splunk Community!

New in Observability - Improvements to Custom Metrics SLOs, Log Observer Connect & ...

The latest enhancements to the Splunk observability portfolio deliver improved SLO management accuracy, better ...

Improve Data Pipelines Using Splunk Data Management

  Register Now   This Tech Talk will explore the pipeline management offerings Edge Processor and Ingest ...

3-2-1 Go! How Fast Can You Debug Microservices with Observability Cloud?

Register Join this Tech Talk to learn how unique features like Service Centric Views, Tag Spotlight, and ...