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!

Exporting Splunk Apps

Join us on Monday, October 21 at 11 am PT | 2 pm ET!With the app export functionality, app developers and ...

Cisco Use Cases, ITSI Best Practices, and More New Articles from Splunk Lantern

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Build Your First SPL2 App!

Watch the recording now!.Do you want to SPL™, too? SPL2, Splunk's next-generation data search and preparation ...