in reply to Re^2: pattern matching once
in thread pattern matching once

To help us communicate without going around in circles, please read and try to follow:

Here is my test program t1.pl:

use strict; use warnings; # Small standalone test program derived from [id://11153804] # @lines contains some test lines derived from: # https://www.sec.gov/Archives/edgar/data/831001/000095010323011632/00 +00950103-23-011632.txt my @lines = ( '<FILENAME>dp198076_424b2-us2342673.htm', '<FILENAME>dp198076_exfilingfees.htm', '<FILENAME>dp198076_oopswrongextension.htmfred', ); foreach my $line (@lines) { print "line:$line:\n"; if ($line =~ m/<FILENAME>(.*\.htm)/) { print " matched line: filename='$1'\n"; } else { print " did not match line\n"; } }

When I run this program, this is what I see:

line:<FILENAME>dp198076_424b2-us2342673.htm: matched line: filename='dp198076_424b2-us2342673.htm' line:<FILENAME>dp198076_exfilingfees.htm: matched line: filename='dp198076_exfilingfees.htm' line:<FILENAME>dp198076_oopswrongextension.htmfred: matched line: filename='dp198076_oopswrongextension.htm'

When I change this line above from:

if ($line =~ m/<FILENAME>(.*\.htm)/) {
to:
if ($line =~ m/<FILENAME>(.*\.htm)\b/) {

when I run this program I see instead:

line:<FILENAME>dp198076_424b2-us2342673.htm: matched line: filename='dp198076_424b2-us2342673.htm' line:<FILENAME>dp198076_exfilingfees.htm: matched line: filename='dp198076_exfilingfees.htm' line:<FILENAME>dp198076_oopswrongextension.htmfred: did not match line

If that is not what you were asking about, please clarify your question by posting a Short, Self-Contained, Correct Example that we can run.

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.