in reply to Regular Expression Help
For $filename, we're just testing for the first five letters, so the {5,} syntax just makes the regex engine do more work.if ($filename =~ /^[A-Z]{5}/) { ($section_title = $filename) =~ s!:!:</B>\n<BR><BR>!; $filename = ""; }
For the actual substitution, the slash in </B> needs to be escaped unless we choose different delimiters like I have above.
Also, we can't do
because the substitution returns a true/false value and if successful, $section_title receives a value of 1. The assignment to $section_title needs to be on a different line or assigned to as above (that's from a suggestion by KM).$section_title = ($filename =~ s/?[:]./':</B>\n< BR>< B>\n');
Cheers,
Ovid
Update: Cleaned up the code in response to KM's point.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: (Ovid) RE: Regular Expression Help
by KM (Priest) on Aug 11, 2000 at 21:02 UTC |