#!/usr/bin/perl
$mystring = "[2004/04/13] The date of this article.";
if($mystring =~ m/(\d+)/) {
print "The first number is $1.";
}
Perl returns 2004, but Kiki and Kodos return /04/. Why that?
Since you did not provide your Python code (or whatever Kiki and Kodos are) then it can be hard to say for sure but my guess is that the pattern syntax for Kiki and Kodos differs from Perl in that you do not need the forward-slash delimiters. For example the equivalent in Python would be:
import re
m = re.search('(\d+)', "[2004/04/13] The date of this article.")
print m.group(0)
Notice that the pattern does not include forward-slashes.
In Perl it's important to realize that the regex operator isn't m, it's the double slashes - /..../ (where .... is actually your regular expression). The m is optional if you use /.
The following are all equivalent:
$mystring =~ m/(\d+)/;
$mystring =~ /(\d+)/;
$var = '(\d+)';
$mystring =~ /$var/;
m// that is the operator, but the m is optional in some circumstances.