[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: OT: matched string of a regular expression

H.S. wrote:

> Then
> $> sed -e 's/\(a(.*)\)1b/\123b/' foo.dat > foo_new.dat
> Or just:
> $> sed -e 's/1b/23b/' foo.dat > foo_new.dat
> if only 1b is to be replaced. Same thing using perl (will replace
> contents of foo.dat inplace):
> $> perl -p -i -e "s/1b/23b/g;" foo.dat
> Regards

perl offers also forward backward lookup in regex, which makes it very

(?: REGEXP ) Like (REGEXP) but does not make back-references.

(?= REGEXP ) Zero width positive look-ahead assertion.

(?! REGEXP ) Zero width negative look-ahead assertion. 


Reply to: