"negative" regexp - Page 2

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

Re: "negative" regexp

  PV> Tad J McClellan 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


Uri Guttman  ------  uri@stemsystems.com  --------  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 ---------

Re: "negative" regexp

Quoted text here. Click to load it

... and in the regular expression language, many UNescaped characters
    also are the character itself!

Quoted text here. Click to load it

You have not given enough information to be able to find it in the
Camel book. What chapter/section? What edition?

Quoted text here. Click to load it

... and it is sometimes "subtraction operator".

Quoted text here. Click to load it

That is not the regular expression language (grammar), that is
in the character class language.

In the Perl language, the character - is subtraction.

In the regular expression language, the character - is not special,
it matches a - character.

In the character class language, the character - forms a range.

You have to know which language you are in before you can properly
discern what all those funny characters mean.

Quoted text here. Click to load it

... in the Perl language.

It is not special in either the regular expression language nor in
the character class language.

Quoted text here. Click to load it

then all you need to know is which language you are currently writing in.

Quoted text here. Click to load it

If you code from ignorance, you end up with ignorant code.

Simply learn Perl and its "mini languages", then you will be really sure,
and your code won't look so embarrassingly amateurish (as well as be
much easier to maintain).

For a bit more on this, see:


Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Re: "negative" regexp

Tad J McClellan wrote:
Quoted text here. Click to load it
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
"needless" parentheses ;-)

Quoted text here. Click to load it
I try it, but I have Czech edition and maybe my translation will not be
accurate or my edition can have more or less pages.

Larry Wall, Tom Christiansen & Randal L. Schwartz
Programming Perl
Original copyright: 1996 O'Reilly and Associates Inc.
Translations: 1997 Computer Press, Pague, Czech Republic

Chapter "2. Basic program parts", page 69 "comparing by paterns"

Code    Meaning
\a          signal
\n          new line
\S         other then blank character

Character "c" preceded by backslash and followed by single character , for
example \cD, is identical with

Any other character preceded by backslash is identical with character itself.

Quoted text here. Click to load it
I endeavour to learn Perl and all its parts, nuances and tricks but I'm from
"lost postcommunistic generation". Now I'm 50+ and I started learn English
only few years ago, this is too late for man. We had "iron curtain" here 40
years and we had no chance to get informations from "free world". 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. But as you are
older and older then your memory more and more fail to absorb new

But end of lament - I'm happy that we have not communism here now :-) and I
can communicate with any people in the world.
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>

Re: "negative" regexp

Petr Vileta schreef:

Quoted text here. Click to load it

Use "|links -dump" as a filter.

Affijn, Ruud

"Gewoon is een tijger."

Re: "negative" regexp


Quoted text here. Click to load it

Or HTML::FormatText::WithLinks

->(map substr
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,

Re: "negative" regexp

Quoted text here. Click to load it

Or lynx?   (although it does not understand javascript)

Question: does links?



Quoted text here. Click to load it

Site Timeline