<?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 Rex and this perl regex generator in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44561#M10510</link>
    <description>&lt;P&gt;I'm trying to use this niffty regex generator using the perl option.&lt;BR /&gt;
&lt;A href="http://txt2re.com/index-java.php3?s=%3CTAG%5Cb%5B%5E%3E%5D*%3E%28.*?%29%3C/TAG%3E&amp;amp;-24"&gt;http://txt2re.com/index-java.php3?s=%3CTAG\b[^%3E]*%3E%28.*?%29%3C/TAG%3E&amp;amp;-24&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I get the code from that page in perl format and then try to use it in splunk as REX:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex 
("$re1='(file)';    # Word 1
$re2='(:)'; # Any Single Character 1
$re3='(\\/)';   # Any Single Character 2
$re4='((?:\\/[\\w\\.\\-]+)+)';  # Unix Path 1
$re5='( )'; # White Space 1
$re6='(does)';  # Word 2
$re7='( )'; # White Space 2
$re8='(not)';   # Word 3
$re9='( )'; # White Space 3
$re10='(exist)';    # Word 4

$re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10;
if ($txt =~ m/$re/is)
{
    $word1=$1;
    $c1=$2;
    $c2=$3;
    $unixpath1=$4;
    $ws1=$5;
    $word2=$6;
    $ws2=$7;
    $word3=$8;
    $ws3=$9;
    $word4=$10;
}")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here's the error I get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'rex' command: The regex '$re1='(file)'; # Word 1 $re2='(:)'; # Any Single Character 1 $re3='(\/)'; # Any Single Character 2 $re4='((?:\/[\w\.\-]+)+)'; # Unix Path 1 $re5='( )'; # White Space 1 $re6='(does)'; # Word 2 $re7='( )'; # White Space 2 $re8='(not)'; # Word 3 $re9='( )'; # White Space 3 $re10='(exist)'; # Word 4 $re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10; if ($txt =~ m/$re/is) { $word1=$1; $c1=$2; $c2=$3; $unixpath1=$4; $ws1=$5; $word2=$6; $ws2=$7; $word3=$8; $ws3=$9; $word4=$10; }' does not extract anything. It should specify at least one named group. Format: (?&amp;lt;name&amp;gt;...).
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 23 May 2013 19:42:34 GMT</pubDate>
    <dc:creator>tb5821</dc:creator>
    <dc:date>2013-05-23T19:42:34Z</dc:date>
    <item>
      <title>Rex and this perl regex generator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44561#M10510</link>
      <description>&lt;P&gt;I'm trying to use this niffty regex generator using the perl option.&lt;BR /&gt;
&lt;A href="http://txt2re.com/index-java.php3?s=%3CTAG%5Cb%5B%5E%3E%5D*%3E%28.*?%29%3C/TAG%3E&amp;amp;-24"&gt;http://txt2re.com/index-java.php3?s=%3CTAG\b[^%3E]*%3E%28.*?%29%3C/TAG%3E&amp;amp;-24&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I get the code from that page in perl format and then try to use it in splunk as REX:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex 
("$re1='(file)';    # Word 1
$re2='(:)'; # Any Single Character 1
$re3='(\\/)';   # Any Single Character 2
$re4='((?:\\/[\\w\\.\\-]+)+)';  # Unix Path 1
$re5='( )'; # White Space 1
$re6='(does)';  # Word 2
$re7='( )'; # White Space 2
$re8='(not)';   # Word 3
$re9='( )'; # White Space 3
$re10='(exist)';    # Word 4

$re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10;
if ($txt =~ m/$re/is)
{
    $word1=$1;
    $c1=$2;
    $c2=$3;
    $unixpath1=$4;
    $ws1=$5;
    $word2=$6;
    $ws2=$7;
    $word3=$8;
    $ws3=$9;
    $word4=$10;
}")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;here's the error I get:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'rex' command: The regex '$re1='(file)'; # Word 1 $re2='(:)'; # Any Single Character 1 $re3='(\/)'; # Any Single Character 2 $re4='((?:\/[\w\.\-]+)+)'; # Unix Path 1 $re5='( )'; # White Space 1 $re6='(does)'; # Word 2 $re7='( )'; # White Space 2 $re8='(not)'; # Word 3 $re9='( )'; # White Space 3 $re10='(exist)'; # Word 4 $re=$re1.$re2.$re3.$re4.$re5.$re6.$re7.$re8.$re9.$re10; if ($txt =~ m/$re/is) { $word1=$1; $c1=$2; $c2=$3; $unixpath1=$4; $ws1=$5; $word2=$6; $ws2=$7; $word3=$8; $ws3=$9; $word4=$10; }' does not extract anything. It should specify at least one named group. Format: (?&amp;lt;name&amp;gt;...).
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 23 May 2013 19:42:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44561#M10510</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2013-05-23T19:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: Rex and this perl regex generator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44562#M10511</link>
      <description>&lt;P&gt;Well that's Perl CODE, not a regular expression. While that tool seems nifty enough, I think you'll have more headaches trying to grab a raw regex from it than it's worth. Splunk's own field extractor has this kind of functionality, why not use that?&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2013 20:03:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44562#M10511</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2013-05-23T20:03:05Z</dc:date>
    </item>
    <item>
      <title>Re: Rex and this perl regex generator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44563#M10512</link>
      <description>&lt;P&gt;I find the field extractor hard to work with... when you go into extract fields if the data your looking to extract isn't part of the sample then you kinda have a hard time.&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2013 21:21:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44563#M10512</guid>
      <dc:creator>tb5821</dc:creator>
      <dc:date>2013-05-23T21:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Rex and this perl regex generator</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44564#M10513</link>
      <description>&lt;P&gt;you can also use the 'erex' command. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Erex"&gt;http://docs.splunk.com/Documentation/Splunk/5.0.2/SearchReference/Erex&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 May 2013 22:35:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Rex-and-this-perl-regex-generator/m-p/44564#M10513</guid>
      <dc:creator>jbsplunk</dc:creator>
      <dc:date>2013-05-23T22:35:52Z</dc:date>
    </item>
  </channel>
</rss>

