Splunk Search

What is the regular expression to replace a dash '-' in a string with a period '.'

shivac
New Member

12-000-000-222

for the above IP address, i want to change it to 12.000.000.222. pls help.

0 Karma

aaraneta_splunk
Splunk Employee
Splunk Employee

@shivac - Looks like you have a few possible solutions to your question. If one of them provided a working solution, please don't forget to click "Accept" below the best answer to resolve this post. If you still need help, please leave a comment. Don’t forget to upvote anything that was helpful too. Thanks!

0 Karma

somesoni2
Revered Legend

FYI, Options, other than sed are,

....| eval YourIPField=replace(YourIPField,"-",".")

not so good method

...| replace"*-*-*-*" with "*.*.*.*" in YourIPField
0 Karma

vasanthmss
Motivator

Try this,

your base search .. | rex mode=sed field=<your_field> "s/-/./g"

Sample:

|stats c | eval field="12-000-000-222" | table field | rex mode=sed field=field "s/-/./g"

V

cpetterborg
SplunkTrust
SplunkTrust

the sedcmd syntax is:

s/-/./g

Will that work for you?

Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...