|
Home > Archive > Unix questions > December 2006 > Where to find specification of character classes supported by gnu sed
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Where to find specification of character classes supported by gnu sed
|
|
| Mister.Fred.Ma@gmail.com 2006-12-09, 1:37 am |
| Hello,
I've tried, man, info, the online gnu documentation, and gone
googly-eyed. Is there an online specification of of the character
classes recognized by gnu sed? I am using version 4.1.5. Thank you.
| |
| Thomas Gardner 2006-12-10, 7:25 am |
| Look in the manpage for ed, not sed. Sir ed came first, I believe
that's where regular expressions were born, so that's where they're
typically documented. As for your specific question, here's what
the manpage for GNU ed says about character classes:
[char-class]
Matches any single character in char-class. To include a `]'
in char-class, it must be the first character. A range of
characters may be specified by separating the end characters of
the range with a `-', e.g., `a-z' specifies the lower case
characters. The following literal expressions can also be used
in char-class to specify sets of characters:
[:alnum:] [:cntrl:] [:lower:] [:space:]
[:alpha:] [:digit:] [:print:] [:upper:]
[:blank:] [:graph:] [:punct:] [:xdigit:]
If `-' appears as the first or last character of char-class,
then it matches itself. All other characters in char-class
match themselves.
Patterns in char-class of the form:
[.col-elm.] or, [=col-elm=]
where col-elm is a collating element are interpreted according
to locale(5) (not currently supported). See regex(3) for an
explanation of these constructs.
Also, the regex(7) manpage is quite good...
Mister.Fred.Ma@gmail.com wrote:
> Hello,
>
> I've tried, man, info, the online gnu documentation, and gone
> googly-eyed. Is there an online specification of of the character
> classes recognized by gnu sed? I am using version 4.1.5. Thank you.
>
--
To reply by mail, remove all lower case letters in my return address
(ThoMGardner@PostOfficeBOX.COM).
| |
| Bill Marcum 2006-12-10, 7:25 pm |
| On 8 Dec 2006 18:19:15 -0800, Mister.Fred.Ma@gmail.com
<Mister.Fred.Ma@gmail.com> wrote:
> Hello,
>
> I've tried, man, info, the online gnu documentation, and gone
> googly-eyed. Is there an online specification of of the character
> classes recognized by gnu sed? I am using version 4.1.5. Thank you.
>
The character classes are part of regular expressions. Try 'man 7 regex'
or 'info regex'.
--
Let us be charitable, and call it a misleading feature :-)
-- Larry Wall in <2609@jato.Jpl.Nasa.Gov>
| |
| Mister.Fred.Ma@gmail.com 2006-12-11, 7:23 pm |
| On 8 Dec 2006 18:19:15 -0800, Mister.Fred.Ma@gmail.com
<Mister.Fred.Ma@gmail.com> wrote:
>
> I've tried, man, info, the online gnu documentation, and gone
> googly-eyed. Is there an online specification of of the character
> classes recognized by gnu sed? I am using version 4.1.5. Thank you.
Bill Marcum wrote:
>
> The character classes are part of regular expressions. Try 'man 7 regex'
> or 'info regex'.
Thomas Gardner wrote:
> Look in the manpage for ed, not sed. Sir ed came first, I believe
> that's where regular expressions were born, so that's where they're
> typically documented. As for your specific question, here's what
> the manpage for GNU ed says about character classes:
>
> [char-class]
> Matches any single character in char-class. To include a `]'
> in char-class, it must be the first character. A range of
> characters may be specified by separating the end characters of
> the range with a `-', e.g., `a-z' specifies the lower case
> characters. The following literal expressions can also be used
> in char-class to specify sets of characters:
>
> [:alnum:] [:cntrl:] [:lower:] [:space:]
> [:alpha:] [:digit:] [:print:] [:upper:]
> [:blank:] [:graph:] [:punct:] [:xdigit:]
>
> If `-' appears as the first or last character of char-class,
> then it matches itself. All other characters in char-class
> match themselves.
>
> Patterns in char-class of the form:
>
> [.col-elm.] or, [=col-elm=]
>
> where col-elm is a collating element are interpreted according
> to locale(5) (not currently supported). See regex(3) for an
> explanation of these constructs.
>
>
> Also, the regex(7) manpage is quite good...
Thank you both. It isn't always clear which regular expression info
applies to which tools, and the knowing which specific rules apply are
very helpful. In addition to "info ed" and "man -s 7 regex", I found
a cool page in "info sed" which I couldn't find before. It is section
"3.9 GNU Extensions for Escapes in Regular Expressions". This is sort
of what I was looking for, because I was hoping to see whether some
escapes could replace charcacter classes. Oddly enough, it is
navigated to by following the link for "3. 'sed' Programs" in the top
info node for sed rather than under Regular Expressions. From there,
the link is called "Escapes:: Specifying special characters". The
reasons I missed it is because I was looking for something specific to
gnu extensions.
|
|
|
|
|