[EMAIL PROTECTED] wrote:
>
> At 02:48 AM 1/20/00 -0800, [EMAIL PROTECTED] wrote:
> >Here's the fixed and improved function and rules:
> excellent!
>
> this is a candidate for storing as a separate
> script library element with your name on it.
>
> set it up so we can call
> do %simple_re.r
> from within wiki.r
>
Cool!
>
> 5. You don't specify whether the front and end anchors ("^" and "$"
> respectively) must appear at the beginning (or end) of the string.
>
In traditional REs, ^ matches the beginning of the searched string
and should only appear at the beginning of a pattern (or a
pattern alternative). By this rule,
^(icimjs|bobr)
is OK, and equivalent to
(^icimjs|^bobr)
(although I didn't notice any beginning-of-line alternatives in
bobr's initial examples). However
some^thing
is bogus, as it would require "some" to appear BEFORE the beginning
of the string.
Corresponding mirror-imaged rules apply for $ where
(com|net|org)$
is actually equivalent to
(com$|net$|org$)
(but the first usage is more common).
Perl 5 added a switch/refinement which allows ^ and $ to match the
beginning and ending of a LINE within strings containing embedded
\n characters, but that's too cruel to throw into the discussion
at this point -- and way beyond what I understood bobr to be
asking for.
>
> Neither do you mention whether not ("?!") must appear at the
> beginning of the string. I assume that your example indicates that
> this is an implied rule.
>
The full syntax is
(?!pattern)
where pattern is any regular expression. The simple usage in bobr's
example simply applied it to the entire match, so that
^(?!(per|jav|vb))
will match any string that DOESN'T begin with one of the listed
alternatives. However, it doesn't have to be used only at the
beginning of a pattern. Again, any examples I can think of take
us into areas of RE syntax that go beyond what bobr was asking
for, AFAICT.
-jn-