Splunk Search

Is there any way of searching for any character follow by comma using rex

rajivchadha
New Member

Does splunk rex have a concept of doing a .*, in the rex function? I basically want to search for any character followed by a comma.

Tags (2)
0 Karma
1 Solution

javiergn
Super Champion

Does "any character" include commas too?

If not, you can possibly do it like this:

"[^\,]+\,"

Which reads as 1 or more non-comma characters followed by a comma.

You can then group all of that in a token you want to capture, and problem solved.

| rex "(?<fieldnameFoo>[^\,]+)\,"

Thanks,
J

View solution in original post

0 Karma

jkat54
SplunkTrust
SplunkTrust

In regex . stands for any character and \, stands for comma.

So

  | rex (?<anyChar>.)\, 

Should work

However if you're not wanting to extract the field and instead you're just searching for it, use the regex command.

   | regex .\,
0 Karma

rajivchadha
New Member

I tried the rex command like below and it did not work as per your suggestion

index="md_dev" ( "Subscribe for") | rex max_match=0 "(?identifier=.*\,)"

also tried

index="md_dev" ( "Subscribe for") | rex max_match=0 "(?identifier=[.]*\,)"

which did not work

0 Karma

javiergn
Super Champion

Does "any character" include commas too?

If not, you can possibly do it like this:

"[^\,]+\,"

Which reads as 1 or more non-comma characters followed by a comma.

You can then group all of that in a token you want to capture, and problem solved.

| rex "(?<fieldnameFoo>[^\,]+)\,"

Thanks,
J

0 Karma

rajivchadha
New Member

Thanks. I tried what you suggested and it worked.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...