Splunk Search

rex field extraction

swetasoneji
New Member

How would I extract account number here,

message:Receiving exp from: Long URL /Eex for account(s): 8768

rex field=_raw "Exposure for account(s):\s+(?[^,]+)"

It neither brings result nor error.

Tags (1)
0 Karma
1 Solution

FrankVl
Ultra Champion

Your message sample says /Eex, your regex starts with "Exposure". Is that just a typo or so in your sample, otherwise that could be one of the issues.

Also:

  • If you want to actually match a ( character, you need to escape it
  • your capturing group needs to be named, such that it will get put into a field

To keep it simple (you can enhance it if you need), something like this should work:

| rex field=_raw "account\(s\):\s+(?<account_number>\d+)"

See also: https://regex101.com/r/ELFlV3/1

View solution in original post

0 Karma

swetasoneji
New Member

can you please elaborate? I'm fairly new to splunk

0 Karma

elliotproebstel
Champion

Sure! This isn't a Splunk thing per se, but rather more about how to post your question here. It looks like part of your rex command is getting eaten up by the formatting here, so it's hard to diagnose.

When you post code, it's best to click the button that looks like 101010 so that your code can be escaped and all characters preserved. If you can't find that button, you can use a single backtick (the character at the top left of your keyboard, on the same key as the ~ tilde) before and after your code.

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!

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

    Thursday, June 25, 2026  |  11AM PDT / 2PM EDT  Duration: 1 Hour (Includes live Q&A) Register to ...

Analytics Workspace deprecation

As of Splunk Cloud Platform 10.4.2604 and Splunk Enterprise 10.4, Analytics Workspace is now deprecated. ...

Splunk Developer Day Recap: Building, Publishing, and Growing on the Splunk Platform

Splunk Developer Day brought the Splunk developer community together for a practical look at what it means to ...