On 2024-04-07 01:10, Lawrence Velázquez wrote:
Yeah, nesting like that would have to work. It's hard on the eyes at first but the step by step substitution logic is there. But I wonder why this doesn't work:On Sat, Apr 6, 2024, at 10:57 AM, Ray Andrews wrote:var=( ${(M)var:#*(#i)$substring*} ) var=( ${var//(#bi)($substring)/aaa${match[1]}bbb} ) ... can those to operations be combined? If a string exists in a variable, modify it, else delete it?var=(${${(M)var:#*(#i)$substring*}//(#bi)($substring)/aaa${match[1]}bbb})
var=( ${(M)var//(#bi)($substring)/aaa${match[1]}bbb} ) ... seems to me the (M) would have the same function -- if the substring isn't there to be matched it can't be modified so kill the line. In both cases the rule would be that empty lines are removed. Functionality would be added and AFAICT nothing would be lost or broken. The (M) doesn't throw an error but neither does it do anything. Or ... is this one of those things were it is doing something but I misread the intention?