Splunk Search

Facing issues in Regex of numbers

kamal_jagga
Contributor

I have the following values in the field and need to write regex for this.
Regex :(?P\d\,\d\d\d)

Input

9
19
157
1,500

Now the issue is I don't want "," to appear in the output field.
Expected output
9
19
157
1500

I am not able to find the expression to ignore the ",".

Kindly advise.

0 Karma

gokadroid
Motivator

If you have already regexed out your number in a field say "myNumberField" or the data with "," is in "myNumberField" then can you try this which will remove the "," from the field value:

your query to return myNumberField
| rex mode=sed field=myNumberField "s/,//g"
| table myNumberField
0 Karma

kamal_jagga
Contributor

The issue is i need to write this in myscript and I can only write regex expression there. So, can't write the mode.

0 Karma

gokadroid
Motivator

what script are you writing? does that scripting means doesn't give something locally for you to capture with comma first and then replace in consecutive lines of script?
Can you paste the sample code that you have written and what are trying you achieving out of it so to see if we can help.

0 Karma

kamal_jagga
Contributor

In the script, i will be using this to get the count of the events, which is being processed further.

It is easier to write capture values before and after comma in the regex and merge and use it in the script. But since this is being used for all the sourcetypes and I don't want to update script everywhere.

I am trying to look for options where I can handle it in a single regex, just be eliminating the comma.

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...