Re: "negative" regexp



Tad J McClellan wrote:
Petr Vileta <stoupa@xxxxxxxxxxxxx> wrote:


$html=~s/<\!\-\-.+?\-\->//sig;


Unnecessary backslashes make your code much harder to read
and understand. You should backslash only when you actually
need to.

There is not much point in ignoring case when your pattern
does not contain any letters...


$html =~ s/<!--.+?-->//sg;
Yes, you are right, but O'Reilly book "Programin Perl" say "... any other escaped character is character itself". Maybe this is not correct cite, I have Czech version. In other word the character - is sometime "range operator" say in case [a-z] and character ! sometime mean "not". So for to be sure a character is a character but not operator I'm used to escape all possible ambiguous characters ;-)
--
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your
mail from another non-spammer site please.)

Please reply to <petr AT practisoft DOT cz>

.



Relevant Pages

  • Re: "negative" regexp
    ... >> Unnecessary backslashes make your code much harder to read ... PV> other escaped character is character itself". ... that is chicken programming. ...
    (comp.lang.perl.misc)
  • Re: "negative" regexp
    ... Unnecessary backslashes make your code much harder to read ... escaped character is character itself". ... That is not the regular expression language, ...
    (comp.lang.perl.misc)
  • Re: Please give me a good "rule-of-thumb" for back-slashing in character classes
    ... Second, the characters], -, and ^ are special in a character class. ... (Technically, ^ is only special if its the first character, however). ... Petr Vileta, Czech republic ...
    (comp.lang.perl.misc)