Splunk Search

Having trouble with rex matching wildcards with escaped double quotes

weropitjpoerit
Engager

Hi there, I am having some trouble matching patterns from a search string using the rex command.

I will show the message I am trying to search on, as well as several rex statements that I am using to find and extract certain bits of data (denoted by asterisks) into fields that I use in a table statement. rex statements matching wildcards populated by digits works fine, but I'm not able to match and extract data matching asterisks when they  are within quotes even if I escape them.

| search Message="Error in breakfast table *, table name \"*\". The quick brown fox jumped over the lazy dog. The maximum length of the \"*\" data is currently set to * hotdogs, but the bun length is * inches. Increase the maximum length of the \"*\" bun to at least * inches and retry.*"
| rex "Error in breakfast table (?<breakfast_table>\d+)" | rename breakfast_table as "BT"

| rex "table name \"(?<table_name>[^\"]*)\"" | rename table_name as "TN"
| rex "maximum length of the \"(?<max_bunlength>[^\"]*)\"" | rename max_bunlength as "MB"

| rex "data is currently set to (?<current_length>\d+)" | rename current_length as "Current Length"

 

I am able to pattern match correctly on asterisks because they just represent number values. I am having trouble with asterisks within double quotes. For example, a real message may show "AB" or "Z" but this line will not match it, even though I have confirmed on regex101 that it should be matching the letters AB or Z correctly -> | rex "table name \"(?<table_name>[^\"]*)\"" | rename table_name as "TN"

 

Any suggestions on this?

Labels (2)
0 Karma
1 Solution

weropitjpoerit
Engager

I can't share the _raw event I used but I can mention how I was able to solve this issue.

 

I went through the Extract New Fields process, highlighted the bit of information I needed like so -> \"author\", viewed the generated regex, opened it in search so I could see the full |rex command that was generated, and used that.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

To help with rex questions we really need to see example data.  Please share sanitized events.

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

weropitjpoerit
Engager

I can't share the _raw event I used but I can mention how I was able to solve this issue.

 

I went through the Extract New Fields process, highlighted the bit of information I needed like so -> \"author\", viewed the generated regex, opened it in search so I could see the full |rex command that was generated, and used that.

Get Updates on the Splunk Community!

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had 3 releases of new security content via the Enterprise Security ...

Archived Metrics Now Available for APAC and EMEA realms

We’re excited to announce the launch of Archived Metrics in Splunk Infrastructure Monitoring for our customers ...