I would use something like the following regex
(?:<p:FirstAddressLine1>(?!<\/p))
Is uses a Negative Lookahead
, and will match <p:FirstAddressLine1>
followed by anything other then </p
. If it sees a </p
directly after the first <> it will not match the string.
EXAMPLE USAGE
use strict;
use warnings;
my @lines = <DATA>;
foreach (@lines) {
if ( $_ =~ m/(?:<p:FirstAddressLine1>(?!<\/p))/ ) {
print "The string is NOT empty\n";
}
else {
print "The string is empty\n";
}
}
__DATA__
<p:FirstAddressLine1></p:FirstAddressLine1>
<p:FirstAddressLine1>TEST</p:FirstAddressLine1>
RESULT
The string is empty
The string is NOT empty