Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Regular expressions in zsh



zzapper wrote in news:Xns9E95A9D1688C0zzappergmailcom@80.91.229.10:

> Phil Pennock wrote in news:20110219054807.GA57597@xxxxxxxxxxxxxxxxxxxx:
> 
> 
>> 
>> zsh has had -pcre-match for a very long time; it's only the =~ operator
>> which is newish; note that if you're a Perl fan, then you might:
>> 

with a little help from zsh-lovers webpage

zmodload zsh/pcre
setopt REMATCH_PCRE

var=ddddd; [[ "$var" =~ ^d+$ ]] && echo matched || echo did not match

var=dddee; regexp="^e+$"; [[ "$var" =~ $regexp ]] && echo $regexp matched 
$var || echo $regexp did not match $var

# above should be on one line


-- 
zzapper
http://zzapper.co.uk/ Technical Tips



Messages sorted by: Reverse Date, Date, Thread, Author