On 01:26 27 Jan 2002, Nick Wilson <[EMAIL PROTECTED]> wrote:
| * and then Cameron Simpson blurted....
| > man perlre
| > 
| > man egrep
| > 
| > Both tell you quite a lot.
| 
| Yes, thanks Cameron,

Bear in mind that there is some variance in regexps.

ed and sed and grep and vi have the core regexp syntax.
Egrep and perl and python and recent vi clones (vim, nvi) and emacs
have "full" or "extended" regexps.

Perl and python and java 1.4+ have POSIX regexps (which handle Unicode etc
and have extensions for character classes for locale support).

| Anyway, I checked out the man grep page and although I could kinda get
| it. it's very 'immediately technical' and more than a little daunting.
| Stil, I'm up for it.

The core notion is that most characters stand for themselves, so:

        stand

is a regexp to match the string "stand". All the rest is frills.
The core specials are:

        \       The next character _is_not_ special. Eg: \. for a literal dot.
        ^       start of line, eg: ^first
        $       end of line, eg: last$
        .       and single character (usualy except for newline),
                eg: a.c matches abc and a-c etc
        [a-z]   a single character in the range
        [^a-z]  a single character not in the range
        ()      grouping
        |       alternation within a group, eg:
                        the car is (red|blue|yellow)
                    matching
                        the car is red
                    or
                        the car is blue
                    etc
        *       0 or more of the previous item, eg:
                        .*      0 or more characters
                        ba*d    bd or bad or baad or ...
        +       1 or more of the previous item, eg:
                        ^(re: *)+
                to match "re:", possibly with following spaces,
                as many times as it occurs at the beginning of the line,
                handy for tidying up Subject: lines like
                        Subject: re: re:re: topic

There's more, but those are the basics. "Basic regexps" don't have + or
() or |, except for sed and vi with have () but they need special marking
as \( and \) (for historical backwards compatibility). Full regexps have
the rest and _don't_ need sloshes (\\) on the ( and ) specials.
-- 
Cameron Simpson, DoD#743        [EMAIL PROTECTED]    http://www.zip.com.au/~cs/

Through and through the world is infested with quantity. To talk sense is to
talk quantities. It is no use saying the nation is large- how large? It is no
use saying that radium is scarce- how scarce? You can not evade quantity. You
may fly to poetry and music and quantity and number will face you in your
rythmns and your octaves.       - Alfred North Whitehead



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to