Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Re: A Perl aptitude test

by halley (Prior)
on May 02, 2003 at 23:13 UTC ( #255192=note: print w/replies, xml ) Need Help??


in reply to Re: Re: A Perl aptitude test
in thread A Perl aptitude test

I contend that (?{ }) is not a regular expression, but a hook (a place for a Perl expression) to be evaluated by the regex engine during its matching work.

The phrase "Regular Expression" is a mathematical concept predating perl and emacs and sed. Quoting from Freidl's Mastering Regular Expressions:

    The Origins of Regular Expressions

    The seeds of regular expressions were planted in the early 1940s... Through the 1950s and 1960s, regular expressions enjoyed a rich study in theoretical mathematical circles... Ken Thompson's 1968 article Regular Expression Search Algorithm... led to his work on qed, an editor that formed the basis for the Unix editor, ed.

Regular expressions are expressions that regulate a sequence as belonging to a set, or not belonging to a set. (What, you thought 'regular' as in 'everyday' or 'fixed interval'?)

Since (?{}) doesn't fail and cause the engine to backtrack or bail, it's not regulating anything. The regex syntax handles the wrapping stuff but the contents are what's doing the string-modifying, and the results have no direct bearing on the regulation. That's what I mean when I say that (?{}) is not a regular expression.

(I know, I'm forever editing and extending my comments with afterthoughts rather than creating new followups.)
--
[ e d @ h a l l e y . c c ]

Replies are listed 'Best First'.
Re^4: A Perl aptitude test ("regular" expressions)
by Aristotle (Chancellor) on May 03, 2003 at 01:09 UTC
    Well, even the regulating pieces of Perl's "regular expressions" are far from regular in any sense of the precise definition. The name just (incorrectly) stuck. (Recent Camels talk of "pattern matching"; I prefer that term too.) Finally, you also forget (??{ code }), which can both alter the string as well as regulate the match in procession.

    Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://255192]
help
Chatterbox?
[Corion]: And the second rule that I've learned is, that there is no one-off job, so writing a program for it pays off almost immediately. The third rule is to give all my programs numbers and have them reproduce that number in the name of their output files. :)
[Discipulus]: the true part is that also specification change between years.. but well our job is cheap but dont abuse of us.. ;=)
[LanX]: Choroba: do you miss chaos with ties? apply at the US government.. ;)
[ambrus]: Corion: those are good rules.
[ambrus]: Discipulus: oh sure. the input data has different filenames every time I get them.
[ambrus]: the directory structure may be 1, 2, or 3 deep, it may have spaces in the filename or not, it has dates in various format, different keywords for the same meanings, and the dates and other keywords are assembled in various ways.
[Discipulus]: no ambrus by specification i mean for example license per core instead of per socket, so fields are different

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (14)
As of 2017-03-29 12:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (350 votes). Check out past polls.