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

Re: Un-patch: new pattern matching code



On Aug 7,  1:02pm, Andrej Borsenkow wrote:
} Subject: RE: Un-patch: new pattern matching code
}
} >
} > The other cpp definition is BACKREFERENCES
} 
} If e.g. the result of last pattern mathing is
} available (much like in Perl) as, say, ``pattern'' array

I'd name it something other than `pattern' ... what's in the array is not
the patterns, it's the matched substring of the source string, right?

} I am not sure, that there is easy
} way in Zsh to extract matched subpattern currently)

There is ${(MSI:n:)...#...}, where n is a number.  BTW, it looks like (M)
doesn't work right with ${.../...}.  Am I missing something?

zagzig% x="abcdefghij"
zagzig% echo ${x/??}
cdefghij
zagzig% echo ${(M)x/??}
cdefghij
zagzig% echo ${(MS)x/??}
cdefghij
zagzig% echo ${(MSI:1:)x/??} 
cdefghij
zagzig% echo ${(MSI:2:)x/??} 
adefghij
zagzig% echo ${(RSI:2:)x/??} 
adefghij
echo ${(MSI:2:)x//??} 
ab
zagzig% echo ${(M)x#??}
ab
zagzig% echo ${(MSI:2:)x#??} 
bc


-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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