Re: "negative" regexp



"PV" == Petr Vileta <stoupa@xxxxxxxxxxxxx> writes:

PV> 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;
PV> Yes, you are right, but O'Reilly book "Programin Perl" say "... any
PV> other escaped character is character itself". Maybe this is not
PV> correct cite, I have Czech version. In other word the character - is
PV> sometime "range operator" say in case [a-z] and character ! sometime
PV> mean "not". So for to be sure a character is a character but not
PV> operator I'm used to escape all possible ambiguous characters ;-)

that is chicken programming. it leads to noise and potentially buggy
programs. i wouldn't accept it for any production code or code that i
review.

uri

--
Uri Guttman ------ uri@xxxxxxxxxxxxxxx -------- http://www.sysarch.com --
----- Perl Architecture, Development, Training, Support, Code Review ------
----------- Search or Offer Perl Jobs ----- http://jobs.perl.org ---------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
.



Relevant Pages

  • Re: "negative" regexp
    ... Unnecessary backslashes make your code much harder to read ... escaped character is character itself". ... In other word the character - is sometime "range operator" say in case and character! ... Petr Vileta, Czech republic ...
    (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: sub is odd with #
    ... quoted string is an escaped character). ...
    (comp.lang.ruby)
  • Re: "negative" regexp
    ... other escaped character is character itself". ... Of course, sir;-) But if I'm not sure if character could be operator then I escape it, if I'm not sure about precedence in calculation then I add ... When you are 20 or 30, then you can learn 2-3 human languages and many programming languages because your memory is able to absorb informations. ...
    (comp.lang.perl.misc)
  • Re: sub is odd with #
    ... quoted string is an escaped character). ...
    (comp.lang.ruby)