worley@compass.com (Dale Worley) (06/27/90)
There are a number of features that could be put into regexp matching that would make life easier: a \- b Match any string which matches a but is not matched (in its entirity) by b. \- b Match the null string if what follows this position is not matched by b. a \: b \; c Match b but only if its left context is matched by a and its right context is matched by c. This would be useful for simplifying s/ / / constructions: s/(a)b(c)/\1d\2/ becomes s/a\:b\;c/d/ Probably, a should be included in $` and c in $'. How hard would this be to do? Dale Worley Compass, Inc. worley@compass.com -- If people think nature is their friend, then they sure don't need an enemy. --Kurt Vonnegut
lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) (06/28/90)
In article <1990Jun27.144859.15573@uvaarpa.Virginia.EDU> worley@compass.com writes:
: There are a number of features that could be put into regexp matching
: that would make life easier:
:
: a \- b
:
: Match any string which matches a but is not matched (in its entirity)
: by b.
:
: \- b
:
: Match the null string if what follows this position is not matched by
: b.
:
: a \: b \; c
:
: Match b but only if its left context is matched by a and its right
: context is matched by c. This would be useful for simplifying s/ / /
: constructions:
:
: s/(a)b(c)/\1d\2/
:
: becomes
:
: s/a\:b\;c/d/
:
: Probably, a should be included in $` and c in $'.
:
: How hard would this be to do?
I don't think "hard" is the quite right question. I have three problems with
this:
1) It's non-standard, so people won't think to use it. Hence
it would tend to be excess baggage.
2) After scratching my head for some time, I can't think what
all the ramifications of the first two constructs might be.
And I think there are a certain number of people in the world
who are more confusable than me.
3) I am opposed to backwhacking punctuation to make metacharacters,
for readability and quotability reasons.
But it would be nice to be able to do boolean lookahead. Someday I might
make it possible to call subroutines within a pattern to allow this
sort of semantics. It looks cleaner to me.
Larry