<?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: Could you please help me with using REX/REGEX inside eval? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593147#M206451</link>
    <description>&lt;P&gt;Given that the only time you change user is if signature is 87347 and in that instance you want everything before the&amp;nbsp;@, just use split&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval account=if(like(signature,"87347"),mvindex(split(user,"@"),0),user)&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 08 Apr 2022 17:36:54 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-04-08T17:36:54Z</dc:date>
    <item>
      <title>Could you please help me with using REX/REGEX inside eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593132#M206447</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Could you please help me with using REX/REGEX inside eval? Here is what I'm trying to do&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| makeresults
| eval User="user1=test@domain.com | use1=test1"
| makemv delim="|" User | mvexpand User
| fields - _time
| eval signature="87347,123,1,0,84"
| makemv signature delim=","
| mvexpand signature
| eval account=if(like(signature,"87347") AND like(User,"%@%" )," REGEX USER TO KEEP EVERYTHING BEFORE @ "," DONT MAKE ANY CHANGES , KEEP THE USER WITH @")&lt;/LI-CODE&gt;
&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2022 15:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593132#M206447</guid>
      <dc:creator>usscommunity</dc:creator>
      <dc:date>2022-04-08T15:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: Could you please help me with using REX/REGEX inside eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593147#M206451</link>
      <description>&lt;P&gt;Given that the only time you change user is if signature is 87347 and in that instance you want everything before the&amp;nbsp;@, just use split&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval account=if(like(signature,"87347"),mvindex(split(user,"@"),0),user)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 08 Apr 2022 17:36:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593147#M206451</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-04-08T17:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Could you please help me with using REX/REGEX inside eval?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593200#M206472</link>
      <description>&lt;P&gt;An alternative is to use&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/TextFunctions#replace.28X.2CY.2CZ.29" target="_blank" rel="noopener"&gt;replace&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval account=if(like(signature,"87347"),replace(user,"@.*",""),user)&lt;/LI-CODE&gt;&lt;P data-unlink="true"&gt;Like ITWhisperer said, you do not need to test for %@%&amp;nbsp;&amp;nbsp;if your final operation is to get rid of&amp;nbsp;@%. &amp;nbsp;In the code you illustrated, the test for &lt;FONT face="courier new,courier"&gt;signature&lt;/FONT&gt; also do not include wildcard. &amp;nbsp;Therefore,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;like(signature, "87347")&lt;/FONT&gt; is semantically identical to &lt;FONT face="courier new,courier"&gt;signature=="87347"&lt;/FONT&gt;, but slightly more expensive. &amp;nbsp;Thanks for bring my attention to function "like()", BTW. &amp;nbsp;I only used match() before.&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2022 22:39:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Could-you-please-help-me-with-using-REX-REGEX-inside-eval/m-p/593200#M206472</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-04-09T22:39:43Z</dc:date>
    </item>
  </channel>
</rss>

