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

Re: Feature request: #a (approximate matching) only for spaces



On Feb 19, 11:13am, Bart Schaefer wrote:
} Subject: Re: Feature request: #a (approximate matching) only for spaces
}
} On Feb 19,  7:21am, Sebastian Gniazdowski wrote:
} } 
} } Can be resulting pattern put into $parameter for later use by $~parameter?
} 
} You might be able to work out a way to do so, but it'd be difficult to get
} the quoting right so that arrays were processed before joining etc.

Fiddled with this a little; here's the formulation that can be assigned
(in double quotes) to a parameter and/or used with $ary[(R)pattern]:

(${(j:|:)${i::=1}+${(@)${:-$INPUT"${(@)^${(s::)INPUT}/?/}"}:s/(#b)(#s)(?(#c$[i++]))/${match[1]}*}})*

So for example in the zsh source tree:

torch% () {
function> integer i=0
function> local INPUT=con
function> local -a files=(*) match
function> print -r --
$files[(R)(${(j:|:)~${i::=1}+${(@)${:-$INPUT"${(@)^${(s::)INPUT}/?/}"}:s/(#b)(#s)(?(#c$[i++]))/${match[1]}*}})*]
function> }
config.status
torch% 

All that was really necessary was to add (@) after +${ but note that any
pattern characters in $INPUT will become active again in the subscript.



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