On 6/19/2001 9:33 AM, "Brandon Barker" <[EMAIL PROTECTED]> wrote:

> I'm having trouble writing a script that will remove the regular
> expression "<B>" in a text file in macperl.
...

>       $newsFile =~ s/<B>//g;


*If* you're parsing HTML, it might be safer to use:
    $newsFile =~ s/<B>//ig;

So that the entirely valid construction "<b>" will also be removed.

And, you might want the following instead:
    $newsFile =~ s/<\/?B>//ig;
So that both open and close tags are removed.


This brings up another question for the gurus out there:
I tend to backslash just about all punctuation marks, especially those that
have special meaning(s) in perl. Thus I would have written:
    $newsFile =~ s/\<\/?B\>//ig;


In general, is this a good habit on my part, or is it frowned upon because
it clutters the code? I've written perl in a vacuum for so long that I've
lost touch with the etiquette.

--Shelly


-----------------------------------------------------------
Shelly Spearing
Systems Engineer, LANL Advanced Accelerator Applications
AAA Project Director's Office
http://aaa.lanl.gov/atw
[EMAIL PROTECTED], MS H836, 505-665-0587  FAX: 505-667-0449


"A smart mind is like a parachute: neither functions when closed."
 

Reply via email to