<?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 Eval random function. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691582#M235472</link>
    <description>&lt;P&gt;How do I format a returned int into a phone number with the hyphen using the eval random function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval PhoneNumber = (random() )&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2024 15:10:44 GMT</pubDate>
    <dc:creator>Substance82</dc:creator>
    <dc:date>2024-06-25T15:10:44Z</dc:date>
    <item>
      <title>Eval random function.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691582#M235472</link>
      <description>&lt;P&gt;How do I format a returned int into a phone number with the hyphen using the eval random function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I have so far:&amp;nbsp;&lt;/P&gt;&lt;P&gt;| eval PhoneNumber = (random() )&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 15:10:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691582#M235472</guid>
      <dc:creator>Substance82</dc:creator>
      <dc:date>2024-06-25T15:10:44Z</dc:date>
    </item>
    <item>
      <title>Re: Eval random function.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691586#M235473</link>
      <description>&lt;P&gt;It depends on the format of phone number that you want and any range constraints on the number.&lt;/P&gt;&lt;P&gt;Essentially, random() returns a "random" potentially large integer. This is usually reduced in range by using a modulus operation. e.g.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval number=random() % 1000000&lt;/LI-CODE&gt;&lt;P&gt;This will give you an integer below a million. Alternatively, you could randomise parts of the number e.g.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval number = "1-".printf("%0.3d", random() % 1000)."-".printf("%04d", random() %10000)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 25 Jun 2024 15:22:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691586#M235473</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-06-25T15:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Eval random function.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691588#M235474</link>
      <description>&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;random&lt;/FONT&gt; function only returns an integer and there is no way to force it to include hyphens in the output.&lt;/P&gt;&lt;P&gt;Since the function may return an integer too small for a phone number, I suggest using multiple calls to build it.&amp;nbsp; Here's an example using the North American Numbering Plan.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval PhoneNumber = (random() % 1000)."-".(random() % 1000)."-".(random() % 10000)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additional massaging may be needed if you want more realistic phone numbers (no "001" for an area code, for example).&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 15:27:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691588#M235474</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2024-06-25T15:27:44Z</dc:date>
    </item>
    <item>
      <title>Re: Eval random function.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691589#M235475</link>
      <description>&lt;P&gt;Thanks for the reply. I actually need a 7 digit format like " 555-XXXX".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 15:33:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691589#M235475</guid>
      <dc:creator>Substance82</dc:creator>
      <dc:date>2024-06-25T15:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Eval random function.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691590#M235476</link>
      <description>&lt;P&gt;where the last 4 digits contain any number from 0 to 9&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 15:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Eval-random-function/m-p/691590#M235476</guid>
      <dc:creator>Substance82</dc:creator>
      <dc:date>2024-06-25T15:35:16Z</dc:date>
    </item>
  </channel>
</rss>

