Splunk Search

issue in regex

pragycho
Loves-to-Learn

Hi ,

i  want to ignore some comment line and last comment  store value in field.

for example  , I have log where first  3 line field is in commented for Version, Date, Software

#Ver: 1.0
#Date: 2020-04-18 11:10:15
#Software: ABC for Web 11.8.0-414

how to write the regex expression for this where i can store last field value

my regex REGEX = ^\#  but it is dropping all lines with leading hash

how to store  Software value in field but other previous  field  value can drop

Labels (2)
0 Karma

tscroggins
Champion

@pragycho 

To exclude all lines beginning with # except for #Software in a transform evaluated at index time, try:

^#(?!Software)

To extract the text after #Software: into a field in a transform at search time, try:

^#Software:\s+(?<software>.*)

This is the equivalent rex command:

| rex "^#Software:\s+(?<software>.*)"

I can provide more detailed conf examples if you can provide a little more context around where (index time or search time) you want to discard lines and extract values.

0 Karma

pragycho
Loves-to-Learn

i have Regex in transform.com .

which is good for performance

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...