Splunk Search

Regex to remove single quote

allladin101
Explorer
index=whatever* sourcetype=server  earliest=-3d  | table  USERNAME CLIENT_VERSION_IN |where NOT isnull(SU_USERNAME_IN)|where CLIENT_VERSION_IN=*07_2*

CLIENT_VERSION_IN=*07_2* doesnot seem to work as the value here 'XF_07_2_5474'. Can some one help build a rex or regex so that i could get the data.

Thanks

Tags (4)
0 Karma
1 Solution

MuS
SplunkTrust
SplunkTrust

Hi alladin101,

if you want to get something between two ' single quotes, try something like this:

... | head 1 | eval foo="'XF_07_2_5474'" | rex field=foo "\'(?P<myfoo>.+)\'" | table foo myfo

and the result will be like this:
alt text

hope this helps ...

cheers, MuS

View solution in original post

MuS
SplunkTrust
SplunkTrust

Hi alladin101,

if you want to get something between two ' single quotes, try something like this:

... | head 1 | eval foo="'XF_07_2_5474'" | rex field=foo "\'(?P<myfoo>.+)\'" | table foo myfo

and the result will be like this:
alt text

hope this helps ...

cheers, MuS

allladin101
Explorer

this works but i want to use a wild card here in this part :eval foo="'XF_07_2_5474'"

as 5474 may vary. Is that possible?

0 Karma

MuS
SplunkTrust
SplunkTrust

can you mark this as answered as well - thx

0 Karma

cpetterborg
SplunkTrust
SplunkTrust

In terms more close to your question, with MuS's reply, use:

index=whatever* sourcetype=server  earliest=-3d  | table  USERNAME CLIENT_VERSION_IN | rex field=CLIENT_VERSION_IN "\'(?P<fixedfield>.+)\'" | table CLIENT_VERSION_IN fixedfield

Completely generic for your case as provided.

0 Karma

MuS
SplunkTrust
SplunkTrust

I must admit, I don't fully understand your intensions but sure this will work:

| eval foo="'XF_07_2_*'" | rex field=foo "\'(?P<myfoo>.+)\'" | table foo myfoo

will result in a table looking like this:

foo                  myfoo
'XF_07_2_*' XF_07_2_*
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 ...