Re: Negative lookahead regex clarification needed
From: Anno Siegel (anno4000_at_lublin.zrz.tu-berlin.de)
Date: 01/25/05
- Next message: A. Sinan Unur: "Re: Grep Text File for Lines Containing 1 or 2 Words"
- Previous message: clarence_at_silcom.com: "Re: Simple use-vs-require problem"
- In reply to: shifty: "Re: Negative lookahead regex clarification needed"
- Next in thread: Tad McClellan: "Re: Negative lookahead regex clarification needed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 25 Jan 2005 22:18:14 GMT
shifty <shifty_MyU@yahoo.com> wrote in comp.lang.perl.misc:
>
> > Something is going to compile it. Every regex engine in existence
> > does that.
>
> I would guess they're never compiled - regexes are interpreted, eh?
> So, in essence, if I am writing a regex for perl in particular (we'll
> keep it on-topic), perl is an interpreted language and so is a regex,
> so it's processed on the fly instead of compiling it into an object for
> future use. Unless I'm misinterpreting your use of "compile". If so,
> I have a true interest in understanding if you don't mind explaining.
Processing on-the-fly and compilation don't exclude one another. Both
Perl and, on another level, regular expressions, are first compiled
into a more readily executable form and then immediately executed.
There is still a distinct compilation phase for both, and this is the
phase where syntax is checked and syntax errors are detected.
In particular, a regular expression is not interpreted character by
character, but first translated into something else (often, but not
always, a model of a finite-state machine). There's a whole theory
about that.
> > My point was the misuse of "syntax" for "correct code". It's
> becoming a
> > sore spot.
>
> My apologies. I think we have conflicting views on what a regex really
> is. To me, a regex is a sentence or formula which expresses any number
> of meanings. Without the correct characters pattern (and/or placement)
> within the text (and/or string), you don't have a correct statement.
>
> If you don't produce a correct statement because one or more characters
> are misplaced, is it a syntax error or a code error?
If the regex engine cannot translate your string, it's a syntax error.
If it can, but the result doesn't match the intended set of patterns,
it's a semantic error. Both are coding errors.
Your description "without the correct character pattern ... you don't
have a correct statement" covers both kinds of errors. "Syntax error"
means only one.
Anno
- Next message: A. Sinan Unur: "Re: Grep Text File for Lines Containing 1 or 2 Words"
- Previous message: clarence_at_silcom.com: "Re: Simple use-vs-require problem"
- In reply to: shifty: "Re: Negative lookahead regex clarification needed"
- Next in thread: Tad McClellan: "Re: Negative lookahead regex clarification needed"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|