<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to replace a string with RegEx in search result in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/601544#M209353</link>
    <description>&lt;P&gt;I have my Sonicwall logfiles coming into Splunk. By searching this index I want to replace "dst" (Destination IP address) without portnumber and interface with (for example) RegEx. Note that the formats used for "src" and "dst" =&amp;nbsp;&lt;FONT face="courier new,courier" color="#3366FF"&gt;(ip address):(port number):(interface)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;So when I do a search like (NOTE: the red sentence is my own attempt, however, it does not give a result I had in mind.):&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#3366FF"&gt;index=sonicwall msg="Connection Opened" OR msg="Connection Closed" earliest=-2m latest=-1m&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;| eval dst=if(match(dst, "\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:\d{1,5}:X\d{1}"), dst, replace(dst, "(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}):\d{1,5}:X\d{1}","\1"))&lt;/FONT&gt;&lt;BR /&gt;| stats first(_time) as _time by src dst proto msg&lt;BR /&gt;| inputlookup append=t firewall_open_connections&lt;BR /&gt;| fillnull msg value="Connection Opened"&lt;BR /&gt;| eval closed=if(msg="Connection Closed",_time,"1")&lt;BR /&gt;| eval open=if(msg="Connection Opened",_time,"1")&lt;BR /&gt;| stats first(open) as open first(closed) as closed by src dst proto&lt;BR /&gt;| where open &amp;gt; closed&lt;BR /&gt;| rename open as _time&lt;BR /&gt;| fields src dst proto _time&lt;BR /&gt;| outputlookup firewall_open_connections&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Results in:&lt;/P&gt;&lt;TABLE width="671"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;src&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;dst&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;proto&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;_time&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;10.0.1.5:50492:X2&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;8.8.8.8:53:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;udp/dns&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 15:40:08&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;192.168.1.100:37016:X0&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;54.81.233.206:443:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;tcp/https&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 15:39:01&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;192.168.1.100:38376:X0&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;104.244.42.130:443:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;tcp/https&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 14:49:14&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;192.168.1.100:38611:X0&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;172.217.132.170:443:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;udp/https&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 15:37:51&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would like the "dst" &lt;FONT face="helvetica"&gt;results&lt;/FONT&gt; to be stripped of&amp;nbsp;&lt;FONT color="#3366FF"&gt;&lt;FONT face="courier new,courier"&gt;:(port number):(interface)&lt;FONT face="helvetica" color="#000000"&gt;or&lt;/FONT&gt;&amp;nbsp;:(interface)&lt;/FONT&gt;&lt;/FONT&gt;. In other words, only the IP address should remain&lt;/P&gt;&lt;P&gt;How do I do that within my query in Splunk with for example RegEx (or another method)?&lt;/P&gt;&lt;P&gt;Any tip is welcome, am very new to Splunk.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Jun 2022 08:33:04 GMT</pubDate>
    <dc:creator>Dolfing</dc:creator>
    <dc:date>2022-06-15T08:33:04Z</dc:date>
    <item>
      <title>How to replace a string with RegEx in search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/601544#M209353</link>
      <description>&lt;P&gt;I have my Sonicwall logfiles coming into Splunk. By searching this index I want to replace "dst" (Destination IP address) without portnumber and interface with (for example) RegEx. Note that the formats used for "src" and "dst" =&amp;nbsp;&lt;FONT face="courier new,courier" color="#3366FF"&gt;(ip address):(port number):(interface)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;So when I do a search like (NOTE: the red sentence is my own attempt, however, it does not give a result I had in mind.):&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier" color="#3366FF"&gt;index=sonicwall msg="Connection Opened" OR msg="Connection Closed" earliest=-2m latest=-1m&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;| eval dst=if(match(dst, "\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}:\d{1,5}:X\d{1}"), dst, replace(dst, "(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}):\d{1,5}:X\d{1}","\1"))&lt;/FONT&gt;&lt;BR /&gt;| stats first(_time) as _time by src dst proto msg&lt;BR /&gt;| inputlookup append=t firewall_open_connections&lt;BR /&gt;| fillnull msg value="Connection Opened"&lt;BR /&gt;| eval closed=if(msg="Connection Closed",_time,"1")&lt;BR /&gt;| eval open=if(msg="Connection Opened",_time,"1")&lt;BR /&gt;| stats first(open) as open first(closed) as closed by src dst proto&lt;BR /&gt;| where open &amp;gt; closed&lt;BR /&gt;| rename open as _time&lt;BR /&gt;| fields src dst proto _time&lt;BR /&gt;| outputlookup firewall_open_connections&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Results in:&lt;/P&gt;&lt;TABLE width="671"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;src&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;dst&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;proto&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;&lt;A href="http://127.0.0.1:8000/en-US/app/simple_xml_examples/search?earliest=0&amp;amp;latest=&amp;amp;q=search%20index%3Dsonicwall%20msg%3D%22Connection%20Opened%22%20OR%20msg%3D%22Connection%20Closed%22%20earliest%3D-2m%20latest%3D-1m%0A%7C%20eval%20dst%3Dif(match(dst%2C%20%22%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22)%2C%20dst%2C%20replace(dst%2C%20%22(%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D.%5Cd%7B1%2C3%7D)%3A%5Cd%7B1%2C5%7D%3AX%5Cd%7B1%7D%22%2C%22%5C1%22))%0A%7C%20stats%20first(_time)%20as%20_time%20by%20src%20dst%20proto%20msg%0A%7C%20inputlookup%20append%3Dt%20firewall_open_connections%0A%7C%20fillnull%20msg%20value%3D%22Connection%20Opened%22%0A%7C%20eval%20closed%3Dif(msg%3D%22Connection%20Closed%22%2C_time%2C%221%22)%0A%7C%20eval%20open%3Dif(msg%3D%22Connection%20Opened%22%2C_time%2C%221%22)%0A%7C%20stats%20first(open)%20as%20open%20first(closed)%20as%20closed%20by%20src%20dst%20proto%0A%7C%20where%20open%20%3E%20closed%0A%7C%20rename%20open%20as%20_time%0A%7C%20fields%20src%20dst%20proto%20_time%0A%7C%20outputlookup%20firewall_open_connections&amp;amp;display.page.search.mode=fast&amp;amp;dispatch.sample_ratio=1&amp;amp;display.general.type=statistics&amp;amp;display.page.search.tab=statistics&amp;amp;display.visualizations.type=mapping&amp;amp;workload_pool=&amp;amp;display.prefs.statistics.count=100&amp;amp;display.visualizations.mapping.type=choropleth&amp;amp;sid=1655214093.11418" target="_blank" rel="noopener"&gt;_time&lt;/A&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;10.0.1.5:50492:X2&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;8.8.8.8:53:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;udp/dns&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 15:40:08&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;192.168.1.100:37016:X0&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;54.81.233.206:443:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;tcp/https&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 15:39:01&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;192.168.1.100:38376:X0&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;104.244.42.130:443:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;tcp/https&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 14:49:14&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="186"&gt;&lt;P&gt;192.168.1.100:38611:X0&lt;/P&gt;&lt;/TD&gt;&lt;TD width="178"&gt;&lt;P&gt;172.217.132.170:443:X1&lt;/P&gt;&lt;/TD&gt;&lt;TD width="127"&gt;&lt;P&gt;udp/https&lt;/P&gt;&lt;/TD&gt;&lt;TD width="180"&gt;&lt;P&gt;2022-06-14 15:37:51&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I would like the "dst" &lt;FONT face="helvetica"&gt;results&lt;/FONT&gt; to be stripped of&amp;nbsp;&lt;FONT color="#3366FF"&gt;&lt;FONT face="courier new,courier"&gt;:(port number):(interface)&lt;FONT face="helvetica" color="#000000"&gt;or&lt;/FONT&gt;&amp;nbsp;:(interface)&lt;/FONT&gt;&lt;/FONT&gt;. In other words, only the IP address should remain&lt;/P&gt;&lt;P&gt;How do I do that within my query in Splunk with for example RegEx (or another method)?&lt;/P&gt;&lt;P&gt;Any tip is welcome, am very new to Splunk.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Jun 2022 08:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/601544#M209353</guid>
      <dc:creator>Dolfing</dc:creator>
      <dc:date>2022-06-15T08:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string with RegEx in search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602126#M209588</link>
      <description>&lt;P&gt;Hi, I think you want to use the rex command here.&amp;nbsp; In my example below, I am taking the leading four octets of src and dst and putting them into new fields named src_after and dst_after.&amp;nbsp; Everything after the first four octets is ignored.&amp;nbsp; All of the stuff in |makeresults and |spath is just for me to build up some fake data using what you provided.&amp;nbsp; The part you want to look at starts with the |rex steps.&amp;nbsp; I hope this helps.&lt;/P&gt;&lt;PRE&gt;| makeresults | eval json="{ \"src\":\"10.0.1.5:50492:X2\", \"dst\":\"8.8.8.8:53:X1\" }"&lt;BR /&gt;| append [| makeresults | eval json="{ \"src\":\"192.168.1.100:37016:X0\", \"dst\":\"54.81.233.206:443:X1\" }"]&lt;BR /&gt;| append [| makeresults | eval json="{ \"src\":\"192.168.1.100:38376:X0\", \"dst\":\"104.244.42.130:443:X1\" }"]&lt;BR /&gt;| append [| makeresults | eval json="{ \"src\":\"192.168.1.100:38611:X0\", \"dst\":\"172.217.132.170:443:X1\" }"]&lt;BR /&gt;| spath input=json&lt;BR /&gt;| rex field=src "^(?&amp;lt;src_after&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"&lt;BR /&gt;| rex field=dst "^(?&amp;lt;dst_after&amp;gt;\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})"&lt;BR /&gt;| table src src_after dst dst_after&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rymundo_splunk_0-1655396722243.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/20135i5DDD0A8379B07F10/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rymundo_splunk_0-1655396722243.png" alt="rymundo_splunk_0-1655396722243.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 16:26:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602126#M209588</guid>
      <dc:creator>rymundo_splunk</dc:creator>
      <dc:date>2022-06-16T16:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string with RegEx in search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602143#M209592</link>
      <description>&lt;P&gt;You can use replace() function to trim everything from the semicolon to the end of the field.&lt;/P&gt;&lt;PRE&gt;| eval dst=replace(dst,":.*","")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2022 19:22:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602143#M209592</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-06-16T19:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string with RegEx in search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602384#M209672</link>
      <description>&lt;P&gt;Thank you, this is a simple and effective way that I was looking for. Really appreciate it.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 08:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602384#M209672</guid>
      <dc:creator>Dolfing</dc:creator>
      <dc:date>2022-06-20T08:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to replace a string with RegEx in search result</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602385#M209673</link>
      <description>&lt;P&gt;Thank you for your answer. Definitely much appreciated. However, this is not the solution I was looking for because I have to change everything myself or include it in a regex list. However, the examples in my post were only a few lines, but the actual result is thousands of lines.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jun 2022 08:22:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-replace-a-string-with-RegEx-in-search-result/m-p/602385#M209673</guid>
      <dc:creator>Dolfing</dc:creator>
      <dc:date>2022-06-20T08:22:07Z</dc:date>
    </item>
  </channel>
</rss>

