#20 dot doesn't match \r like in Perl

open
nobody
None
5
2006-07-31
2006-07-31
Ryan K
No

I was looking at JRegex as an ORO replacement but
noticed a difference between the two that will keep me
from moving.

The dot "." in Perl matches a carriage return "\r" even
when singleline mode is off. In JRegex the \r is only
matched by the dot with singleline mode turned on.

Here is a quick Perl script that will show the match.
Put the same pattern and text to use with JRegex and it
won't match.

--------------------------------------------------

#!/usr/bin/perl
my $testPattern = "(Kung.*\n)";
my $testText = "Kung Fu\r\nRex Kwan Do\r\n";

print "--------------\nTest Text:
\n$testText\n--------------\n";
print "Test Pattern: \n$testPattern\n--------------\n";

if ($testText =~ /$testPattern/m)
{
print "Matched: \n$1\n--------------\n";
}

Discussion


Log in to post a comment.