Splunk Search

How to correct my regex to extract multiple KB number occurrences in a windowsupdate.log, not just the first?

hagjos43
Contributor

I'm using the following regex to extract KB numbers in the windowsupdate.log

| rex "\((?<KB>KB\d+)\)"

It works, but it only extracts the FIRST occurrence of the KB number.

Here is an example log file:

Security Update for Microsoft Word 2013 (KB2910916) 64-Bit Edition - Definition Update for Microsoft Office 2013 (KB2920752) 64-Bit Edition - Security Update for Windows 7 for x64-based Systems (KB3013455)

How do I tell the regex to repeat until the end of the line?

Thanks!
Joe

0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

This should do it.

.. | rex max_match=0 "\((?<KB>KB\d+)\)" | ...

The KB field will be multivalued so you'll have to use the mv* functions to extract each value.

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

This should do it.

.. | rex max_match=0 "\((?<KB>KB\d+)\)" | ...

The KB field will be multivalued so you'll have to use the mv* functions to extract each value.

---
If this reply helps you, Karma would be appreciated.

hagjos43
Contributor

Perfect! Thanks so much!!!

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