<?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 How to copy/paste a regex into splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107221#M27874</link>
    <description>&lt;P&gt;My ultimate goal is to create a regex expression that can be used use to extract fields from any record made up comma-seperated fields. For example, if a normal event looks like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;"RADSP01HDQRW","IAS",04/02/2012,16:14:38,2,,"RETAIL\HH01-9002",,,,,,,,0,"10.170.191.48"&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;it will always contain 15 commas, therefore 16 fields.&lt;/P&gt;

&lt;P&gt;I created the regex expression below and tested it with  UltraEditPro. &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[^,]&lt;EM&gt;(?=(,[^,]&lt;/EM&gt;){15,15}$)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;It will find the 1st field. In order to make it find the 2nd field I simply replace (15,15) with (14,14).&lt;/P&gt;

&lt;P&gt;Everything looked great in UltraEdit but when I pasted it into the Field Extraction UI&lt;BR /&gt;
it complained... &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Invalid regex: no named extraction at position 7 (i.e., "=(,[^,]*){..."). Expected "(?P&lt;VARIABLE&gt;pattern)"&lt;/VARIABLE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I tried various combinations before thinking surely someone else has already tackled this problem... so here's hoping!&lt;/P&gt;</description>
    <pubDate>Mon, 02 Apr 2012 20:38:06 GMT</pubDate>
    <dc:creator>mikefoti</dc:creator>
    <dc:date>2012-04-02T20:38:06Z</dc:date>
    <item>
      <title>How to copy/paste a regex into splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107221#M27874</link>
      <description>&lt;P&gt;My ultimate goal is to create a regex expression that can be used use to extract fields from any record made up comma-seperated fields. For example, if a normal event looks like this:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;"RADSP01HDQRW","IAS",04/02/2012,16:14:38,2,,"RETAIL\HH01-9002",,,,,,,,0,"10.170.191.48"&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;it will always contain 15 commas, therefore 16 fields.&lt;/P&gt;

&lt;P&gt;I created the regex expression below and tested it with  UltraEditPro. &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[^,]&lt;EM&gt;(?=(,[^,]&lt;/EM&gt;){15,15}$)&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;It will find the 1st field. In order to make it find the 2nd field I simply replace (15,15) with (14,14).&lt;/P&gt;

&lt;P&gt;Everything looked great in UltraEdit but when I pasted it into the Field Extraction UI&lt;BR /&gt;
it complained... &lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;Invalid regex: no named extraction at position 7 (i.e., "=(,[^,]*){..."). Expected "(?P&lt;VARIABLE&gt;pattern)"&lt;/VARIABLE&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;I tried various combinations before thinking surely someone else has already tackled this problem... so here's hoping!&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2012 20:38:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107221#M27874</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2012-04-02T20:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy/paste a regex into splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107222#M27875</link>
      <description>&lt;P&gt;Since you have a delimiter that is separating your fields then I would take a look at the following:&lt;/P&gt;

&lt;P&gt;$SPLUNK_HOME/etc/system/local/props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[data]
REPORT-fieldextract = fieldextract
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;$SPLUNK_HOME/etc/system/local/transforms.conf &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[fieldextract]
DELIMS = ","
FIELDS = field1,field2,field3,...field16
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Remember that this field extraction happens at index time so this will only work for the latest data. &lt;/P&gt;

&lt;P&gt;Here is a link to more information:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.1/Admin/Transformsconf"&gt;http://docs.splunk.com/Documentation/Splunk/4.3.1/Admin/Transformsconf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2012 20:57:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107222#M27875</guid>
      <dc:creator>tgow</dc:creator>
      <dc:date>2012-04-02T20:57:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy/paste a regex into splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107223#M27876</link>
      <description>&lt;P&gt;Thanks for the reply. I read the props and transforms documentation and am unclear if the edits need to be in these files on the indexer or the UF.&lt;/P&gt;

&lt;P&gt;Also, if  I want to extract the csv fields only for sourcetype=foo, does this look right?&lt;/P&gt;

&lt;P&gt;Props.conf [sourcetype::foo]&lt;BR /&gt;
report_radius=extract_radius_CSV&lt;/P&gt;

&lt;P&gt;Transforms.conf: [extract_radius_CSV]&lt;BR /&gt;
DELIMS=”,”&lt;BR /&gt;
FIELDS=”nps_svrName”,”nps_svcName”,”nps_Date”,”nps_Time”,”nps_packetType,”nps_userName”,”nps_userFQDN”,”nps_calledStation”,”nps_callingStation”&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:38:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107223#M27876</guid>
      <dc:creator>mikefoti</dc:creator>
      <dc:date>2020-09-28T11:38:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to copy/paste a regex into splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107224#M27877</link>
      <description>&lt;P&gt;Fields extractions are on the search head then if your indexer is the search head too then you should put it there.&lt;BR /&gt;
Your sencond extraction via delims looks right.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Apr 2012 05:32:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-copy-paste-a-regex-into-splunk/m-p/107224#M27877</guid>
      <dc:creator>MarioM</dc:creator>
      <dc:date>2012-04-06T05:32:22Z</dc:date>
    </item>
  </channel>
</rss>

