<?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: Adding a fieldname to a regex extraction in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18870#M2804</link>
    <description>&lt;P&gt;Thank you both.&lt;/P&gt;

&lt;P&gt;So I changed my search to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;name&amp;gt;(https?:\/\/)?(www)?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?\.[a-z]{2,4})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works when I do a &lt;CODE&gt;... | rex "(?&amp;lt;name&amp;gt;(https?:\/\/)?(www)?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?\.[a-z]{2,4})" | top 50 name&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;However, if I try to save a field extraction with that same regex I get an error"Encountered the following error while trying to update: In handler 'props-extract': Regex: syntax error in subpattern name (missing terminator)". It might be because of my dirty regex.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 04 Feb 2013 19:21:29 GMT</pubDate>
    <dc:creator>agodoy</dc:creator>
    <dc:date>2013-02-04T19:21:29Z</dc:date>
    <item>
      <title>Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18867#M2801</link>
      <description>&lt;P&gt;I have this regex (https?:\/\/)?(www)?(.)?([a-z\d-]{2,})?(.)?([a-z\d-]{2,})?(.)?([a-z\d-]{2,})?.[a-z]{2,4} that I want to use to extract a new field.&lt;/P&gt;

&lt;P&gt;How do I incorporate a field name to that regex to use in field extraction.&lt;BR /&gt;
Thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 18:47:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18867#M2801</guid>
      <dc:creator>agodoy</dc:creator>
      <dc:date>2013-02-04T18:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18868#M2802</link>
      <description>&lt;P&gt;you need to define a special group with &lt;CODE&gt;(?&amp;lt; fieldname &amp;gt;regexmatch)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;read the documentation for examples :&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Rex"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Rex&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 18:58:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18868#M2802</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-02-04T18:58:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18869#M2803</link>
      <description>&lt;P&gt;Hi agodoy,&lt;/P&gt;

&lt;P&gt;To extract fields using the Splunk search language, you will want to use the rex command. This is in the syntax of:&lt;/P&gt;

&lt;P&gt;|rex field=myFieldName "myRegex(?&lt;MYNEWFIELD&gt;regexToMatchValueForMyNewField)anyOtherRegex"&lt;/MYNEWFIELD&gt;&lt;/P&gt;

&lt;P&gt;More info can be found in the &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.1/SearchReference/Rex"&gt;docs.&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Looking at your regex, you may want to clean up the regex a little.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 19:05:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18869#M2803</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2013-02-04T19:05:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18870#M2804</link>
      <description>&lt;P&gt;Thank you both.&lt;/P&gt;

&lt;P&gt;So I changed my search to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;name&amp;gt;(https?:\/\/)?(www)?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?\.[a-z]{2,4})
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It works when I do a &lt;CODE&gt;... | rex "(?&amp;lt;name&amp;gt;(https?:\/\/)?(www)?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?(\.)?([a-z\d\-]{2,})?\.[a-z]{2,4})" | top 50 name&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;However, if I try to save a field extraction with that same regex I get an error"Encountered the following error while trying to update: In handler 'props-extract': Regex: syntax error in subpattern name (missing terminator)". It might be because of my dirty regex.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 19:21:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18870#M2804</guid>
      <dc:creator>agodoy</dc:creator>
      <dc:date>2013-02-04T19:21:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18871#M2805</link>
      <description>&lt;P&gt;nice job mister&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 19:26:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18871#M2805</guid>
      <dc:creator>yannK</dc:creator>
      <dc:date>2013-02-04T19:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18872#M2806</link>
      <description>&lt;P&gt;Thank you sir! Nice job to you as well!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 19:37:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18872#M2806</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2013-02-04T19:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a fieldname to a regex extraction</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18873#M2807</link>
      <description>&lt;P&gt;Quite possibly, I would say that you may want to try doing some atomic grouping. In other words, for all the grouped up stuff in parentheses, like this: &lt;/P&gt;

&lt;P&gt;(https?)...&lt;/P&gt;

&lt;P&gt;Change it to;&lt;/P&gt;

&lt;P&gt;(?:https?)&lt;/P&gt;</description>
      <pubDate>Mon, 04 Feb 2013 19:49:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-a-fieldname-to-a-regex-extraction/m-p/18873#M2807</guid>
      <dc:creator>Rob</dc:creator>
      <dc:date>2013-02-04T19:49:39Z</dc:date>
    </item>
  </channel>
</rss>

