Re: Simple regex question
- From: Icarus Sparry <usenet@xxxxxxxxxxxxxxxxx>
- Date: 24 Jan 2010 22:19:16 GMT
On Sun, 24 Jan 2010 14:23:59 +0100, Janis Papanagnou wrote:
Stephane CHAZELAS wrote:
2010-01-24, 06:11(+01), Janis Papanagnou:
Seebs wrote:[...]
I'm not sure that even ksh can do everything posix REs can.I am confident and quite sure it does. Vice versa; I think the regexp
library will at least have problems emulating ksh's !(...)
construct. Ever tried? In general you'll get extremely bulky results
here! But the class of languages (regular expressions) is the same,
anyway.[*]
[*] N.B. Newer ksh's also support back-references in their
expressions, so strictly speeking, with that feature, they exceed the
Chomsky-3 grammar class as well (analogous to other libraries with
backreference extensions).
Recent versions of AT&T ksh can also convert globbing patterns to
regular expressions (a AT&T variant thereof):
$ ksh -c 'printf "%R\n" "!(...)"'
^(\.\.\.)!$
I didn't knew that ! were a regular expression meta operator in regexp.
The ! _regexp_ meta operator does not seem to produce results on my box.
$ ls
hello hello world helloworld regexp world $ ls !(hello)
hello world helloworld regexp world $ ksh -c 'printf "%R\n"
"!(hello)"'
^(hello)!$
$ ls | egrep '^(hello)!$'
### nothing matched ###
It works well with the known operators + and * etc. resp. +(...) *(...)
etc.
Still interested in an regexp expression conforming to !(...) ext. glob.
The grep from AST will handle this '^(hello)!$' if you give it a -X flag
to enable the augmented expressions.
An instant thought on matching !(hello) with a RE, this is
^([^h].*|h[^e].*|he[^l].*|hel[^l].*|hell[^o].*|hello..*)$
There has been discussion on comp.compilers recently on calculating the
difference between two regular expressions.
.
- Follow-Ups:
- Re: Simple regex question
- From: Kaz Kylheku
- Re: Simple regex question
- From: Janis Papanagnou
- Re: Simple regex question
- References:
- Simple regex question
- From: Tuxedo
- Re: Simple regex question
- From: mallin.shetland
- Re: Simple regex question
- From: Janis Papanagnou
- Re: Simple regex question
- From: Seebs
- Re: Simple regex question
- From: Janis Papanagnou
- Re: Simple regex question
- From: Seebs
- Re: Simple regex question
- From: Janis Papanagnou
- Re: Simple regex question
- From: Seebs
- Re: Simple regex question
- From: Janis Papanagnou
- Re: Simple regex question
- From: Stephane CHAZELAS
- Re: Simple regex question
- From: Janis Papanagnou
- Simple regex question
- Prev by Date: Re: How to run multiple commands in -exec of find command
- Next by Date: Re: Simple regex question
- Previous by thread: Re: Simple regex question
- Next by thread: Re: Simple regex question
- Index(es):
Relevant Pages
|