Splunk Search

Need help with regex to extract "error" from "url :/test.com/error.html"

jw44250
New Member

How to capture only word that has white the start and end : -

1) ERROR
2) url :/test.com/error.html
3) this is my error 2
4) this is my error3

Output
1 only

Search base | regex "\bERROR\b" didnt work

0 Karma

richgalloway
SplunkTrust
SplunkTrust

If you want white space on either end, then you need anchors. Try (?i)^\s+error\s+$.

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

LCM_BRogerson
Path Finder

Hi @jw44250

I'm a little confused on what your expected output is.

If it's only line 1 then | regex "\bERROR\b" should work for. Can you post the output you're getting?

If you're looking for any error "that has white the start and end" (lines 1 and 2) then you'll need something like | regex "(?i)\bERROR\b" where (?i) makes the regex case-insensitive.

0 Karma

niketn
Legend

@jw44250, please explain your query again as it is confusing. From the subject of question seems like you need to extract word error from partial URL, however, in your Output you have listed that only 1st option should be selected.

Also what do you mean by only word that has white the start and end?

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...