Splunk Search

tostring commas and locale specific separators

colinj
Path Finder

My question is whether or not the tostring command is locale specific. If the locale specifies commas as the decimal and periods as the separator will tostring do the the right thing?

It might better if the option was tostring(, "separators").

arturo
Explorer

Where can I configure "commas" as "locale specific" ??

0 Karma

arturo
Explorer

My browser settings ? Just checked on both Safari (Mac OS X) and Chrome and nothing like that it's there ...

Any pointers ?

0 Karma

lguinn2
Legend

It's based on your browser settings.

0 Karma

lguinn2
Legend

Yes, it might be better. But the "commas" operator is locale specific.

[Update] I am wrong. After believing this for a long time, I was chagrined to find that it is untrue. The commas operator of the tostring command inserts commas. Always.

@sowings has a solution:

searchstring
| stats count
| eval count=tostring(count,"commas:)
| rex field=count mode=sed "s/,/./g"

bmunson_splunk
Splunk Employee
Splunk Employee

Actually that isn't complete. This would show 1234.56 as 1.234.56 when it is expected to see 1.234,56
Add an extra 2 lines to fix it.

| eval count=tostring(count,"commas")
| rex field=count mode=sed "s/\./#/g"
| rex field=count mode=sed "s/,/./g"
| rex field=count mode=sed "s/#/,/g"

make it into a macro if you need it a lot.

lguinn2
Legend

And my apologies for not coming back to this answer and fixing it sooner.

0 Karma

mplungjan
Path Finder
0 Karma

mplungjan
Path Finder

Does not seem to be in my Swiss German settings

0 Karma

colinj
Path Finder

So the "commas" operator will do the right thing?

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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...