<?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 Re: using rex mode=&amp;quot;sed&amp;quot; to remove strings surrounded by # characters in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480305#M82364</link>
    <description>&lt;P&gt;Here is one way to do it, using a Run Anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="#4 MyApp\Framework\DB\Adapter\Pdo\Mysql-&amp;gt;_query('SELECT `store_we...', array()) called at [vendor/myapp/framework/DB/Adapter/Pdo/Mysql.php:621]:::#5 MyApp\Framework\DB\Adapter\Pdo\Mysql-&amp;gt;query(MyApp\Framework\DB\Select#b8e969b2c2d6#, array()) called at [vendor/myapp/zendframework1/library/Zend/Db/Adapter/Abstract.php:737]:::#6 Zend_Db_Adapter_Abstract-&amp;gt;fetchAll(MyApp\Framework\DB\Select#b8e969b2c2d6#) called at [vendor/myapp/module-store/App/Config/Source/RuntimeConfigSource.php:87]"
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw
| rex field=_raw mode=sed "s/(#.+?#)([^#]+)(#.*)/\1StaticText\3/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What this does is break up eligible events into 3 parts, substituting the second part with StaticText.&lt;/P&gt;

&lt;P&gt;You can see the regex here: &lt;A href="https://regex101.com/r/1K5YOy/1"&gt;Regex101&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Feb 2020 16:26:48 GMT</pubDate>
    <dc:creator>jpolvino</dc:creator>
    <dc:date>2020-02-28T16:26:48Z</dc:date>
    <item>
      <title>using rex mode="sed" to remove strings surrounded by # characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480304#M82363</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have a series of log entries that are in the form&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#4 MyApp\Framework\DB\Adapter\Pdo\Mysql-&amp;gt;_query('SELECT `store_we...', array()) called at [vendor/myapp/framework/DB/Adapter/Pdo/Mysql.php:621]
#5 MyApp\Framework\DB\Adapter\Pdo\Mysql-&amp;gt;query(MyApp\Framework\DB\Select#b8e969b2c2d6#, array()) called at [vendor/myapp/zendframework1/library/Zend/Db/Adapter/Abstract.php:737]
#6 Zend_Db_Adapter_Abstract-&amp;gt;fetchAll(MyApp\Framework\DB\Select#b8e969b2c2d6#) called at [vendor/myapp/module-store/App/Config/Source/RuntimeConfigSource.php:87]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where the bits between # and # are the only differences between them.&lt;/P&gt;

&lt;P&gt;I wanted to use sed to replace the bits between # and # with a common string so when I do a stats on them they all appear the same and I can get a nice count of how often the error occurred.&lt;/P&gt;

&lt;P&gt;I've tried using &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=Message mode=sed "s/(Select\#[^\#]*\#)/Select/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What would I need to do to replace the portions between the # and # (in this case #b8e969b2c2d6#&lt;/P&gt;

&lt;P&gt;Thanks,&lt;/P&gt;

&lt;P&gt;Kind regards,&lt;/P&gt;

&lt;P&gt;Ian&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 13:06:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480304#M82363</guid>
      <dc:creator>idjagger</dc:creator>
      <dc:date>2020-02-28T13:06:19Z</dc:date>
    </item>
    <item>
      <title>Re: using rex mode="sed" to remove strings surrounded by # characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480305#M82364</link>
      <description>&lt;P&gt;Here is one way to do it, using a Run Anywhere example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="#4 MyApp\Framework\DB\Adapter\Pdo\Mysql-&amp;gt;_query('SELECT `store_we...', array()) called at [vendor/myapp/framework/DB/Adapter/Pdo/Mysql.php:621]:::#5 MyApp\Framework\DB\Adapter\Pdo\Mysql-&amp;gt;query(MyApp\Framework\DB\Select#b8e969b2c2d6#, array()) called at [vendor/myapp/zendframework1/library/Zend/Db/Adapter/Abstract.php:737]:::#6 Zend_Db_Adapter_Abstract-&amp;gt;fetchAll(MyApp\Framework\DB\Select#b8e969b2c2d6#) called at [vendor/myapp/module-store/App/Config/Source/RuntimeConfigSource.php:87]"
| makemv delim=":::" raw
| mvexpand raw
| rename raw AS _raw
| rex field=_raw mode=sed "s/(#.+?#)([^#]+)(#.*)/\1StaticText\3/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What this does is break up eligible events into 3 parts, substituting the second part with StaticText.&lt;/P&gt;

&lt;P&gt;You can see the regex here: &lt;A href="https://regex101.com/r/1K5YOy/1"&gt;Regex101&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 16:26:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480305#M82364</guid>
      <dc:creator>jpolvino</dc:creator>
      <dc:date>2020-02-28T16:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: using rex mode="sed" to remove strings surrounded by # characters</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480306#M82365</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;| rex mode=sed "s/Select#.*?#/Select/g"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;just try it.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Feb 2020 18:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/using-rex-mode-quot-sed-quot-to-remove-strings-surrounded-by/m-p/480306#M82365</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-02-28T18:07:27Z</dc:date>
    </item>
  </channel>
</rss>

