[ILUG] regular expression question
Mark McLoughlin
mark at skynet.ie
Wed Nov 14 12:44:46 GMT 2001
Hi Padraig,
On Tue, 13 Nov 2001, Padraig Brady wrote:
> Cheers, Dave that's it.
> I really wish there was only 1 regexp syntax to learn.
>
> From the man page:
>
> "In basic regular expressions the metacharacters ?, +, {, |, (, and )
> lose their special meaning; instead use the backslashed versions \?, \+,
> \{, \|, \(, and \)."
>
> So I need to do \+ not just + so....
>
> [padraig at pixelbeat findul]$ grep "^/\(usr/lib\|lib\)/[^/]\+$" input.txt
> /lib/libthread_db-1.0.so
> /usr/lib/lib_alchemistmodule.so
This best place to check this out is in /usr/include/regex.h:
/* If this bit is not set, then + and ? are operators, and \+ and \?
* are literals.
If set, then \+ and \? are operators and + and ? are literals. */
#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
and
#define RE_SYNTAX_GREP \
(RE_BK_PLUS_QM | RE_CHAR_CLASSES \
| RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS \
| RE_NEWLINE_ALT)
but of course, its kinda obtuse, so I got confused looking
at it yesterday :-)
Good Luck,
Mark.
More information about the ILUG
mailing list