<?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 Extract Area Code From Phone Numbers in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456616#M129072</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I have a list of telephone numbers of varying length, but all with an area code at the beginning e.g. 44 for the UK.&lt;/P&gt;

&lt;P&gt;What I'm trying to do is put together a regex which looks to see if the first three characters match 350, if they do then extract those 3 digits into my new field, or if they match 44, the extract those 2 digits into the same field.&lt;/P&gt;

&lt;P&gt;This is what I've put together so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=telno "350?(?&amp;lt;area_code&amp;gt;\d{3})|44?(?area_code&amp;gt;\d{2})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've clearly gone wrong, because Splunk is returning a "unrecognised character" error.&lt;/P&gt;

&lt;P&gt;Could someone possibly look at this please and offer some guidance on where I've gone wrong.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
    <pubDate>Thu, 16 May 2019 08:59:36 GMT</pubDate>
    <dc:creator>IRHM73</dc:creator>
    <dc:date>2019-05-16T08:59:36Z</dc:date>
    <item>
      <title>Extract Area Code From Phone Numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456616#M129072</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I wonder whether someone may be able to help me please.&lt;/P&gt;

&lt;P&gt;I have a list of telephone numbers of varying length, but all with an area code at the beginning e.g. 44 for the UK.&lt;/P&gt;

&lt;P&gt;What I'm trying to do is put together a regex which looks to see if the first three characters match 350, if they do then extract those 3 digits into my new field, or if they match 44, the extract those 2 digits into the same field.&lt;/P&gt;

&lt;P&gt;This is what I've put together so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex field=telno "350?(?&amp;lt;area_code&amp;gt;\d{3})|44?(?area_code&amp;gt;\d{2})"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've clearly gone wrong, because Splunk is returning a "unrecognised character" error.&lt;/P&gt;

&lt;P&gt;Could someone possibly look at this please and offer some guidance on where I've gone wrong.&lt;/P&gt;

&lt;P&gt;Many thanks and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 08:59:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456616#M129072</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2019-05-16T08:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Area Code From Phone Numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456617#M129073</link>
      <description>&lt;P&gt;Can you please provide some sample data (Please mask any sensitive data) ? I didn't get your question properly, do you want to extract 350 and 44 into same field or do you want to extract number after 350 and 44 ?&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 09:34:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456617#M129073</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-05-16T09:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Area Code From Phone Numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456618#M129074</link>
      <description>&lt;P&gt;Hi @IRHM73,&lt;/P&gt;

&lt;P&gt;What you're looking for is way easier than what you've built, something like this : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | rex field=telno "(?&amp;lt;area_code&amp;gt;^350|^44)"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will grab 350 if your number starts with that or 44 if it starts with that. Feel free to add the + sign if you need it. You can use &lt;A href="http://www.regex101.com"&gt;www.regex101.com&lt;/A&gt; to validate your regexes it makes everything much easier.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David &lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 10:02:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456618#M129074</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-05-16T10:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Area Code From Phone Numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456619#M129075</link>
      <description>&lt;P&gt;Hi @harsmarvania57 . Thank you for taking the time to reply.&lt;/P&gt;

&lt;P&gt;Your solution worked great.&lt;/P&gt;

&lt;P&gt;Thank you and kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 10:25:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456619#M129075</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2019-05-16T10:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Area Code From Phone Numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456620#M129076</link>
      <description>&lt;P&gt;Hi @DavidHourani . Thank you for your reply and solution. It works great.&lt;/P&gt;

&lt;P&gt;Kind regards&lt;/P&gt;

&lt;P&gt;Chris&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 10:26:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456620#M129076</guid>
      <dc:creator>IRHM73</dc:creator>
      <dc:date>2019-05-16T10:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Area Code From Phone Numbers</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456621#M129077</link>
      <description>&lt;P&gt;Great, earlier I thought that you want area code as number after 350 and 44 &amp;amp; that's why I deleted my answer earlier.&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 10:41:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Extract-Area-Code-From-Phone-Numbers/m-p/456621#M129077</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-05-16T10:41:53Z</dc:date>
    </item>
  </channel>
</rss>

