Dr.Ruud wrote:
Rob Dixon schreef:
scooter:
Can someone help me with the regexp that will match exactly two
quotes(') or no quotes in the string.
If a single quote exists, then will break out.
eg:
aabbcc - Should Match
aa''bb''c''c - Should Match
a''b - Should Match
ab'' - Should Match
aa'bbcc - Should not Match
aa''bb'cc - Should not Match (since there is a single quote)
'aabcc - Should not Match
This does what you have described. It looks for a single quote,
preceded by a character other than a single quote or the start of the
string, and followed by a character other than a single quote or the
end of the string.
if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
print "matches\n"
}
That would fail q{a''''b}.
What do you mean by fail?
use strict;
use warnings;
for (q{a''''b}) {
if (not /(?:\A|[^'])'(?:\Z|[^'])/) {
print "matches\n"
}
}
__END__
prints 'matches'.
I understand this to be correct as the string doesn't contain a solitary
single quote.
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/