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

Re: Feature request (#b)...(...)<not empty>



On Feb 25,  9:54am, Sebastian Gniazdowski wrote:
}
} ${a//(#b)ab(|c)/x} "<- last one shows | isn't greedy"
} x x xc <- last one shows | isn't greedy

Yes, you're correct.  Putting the shorter (in this case empty) alternate
first in the parens makes that particular subexpression non-greedy.  This
was a deliberate choice -- though I can't find that it's been documented
anywhere, on a brief search.

} I'm not sure if regexes work this way.. Maybe I'm loosing it for a
} moment, but:
} 
} [[ abc =~ ab(|c) ]] && echo "I've tried multiple options"
} zsh: failed to compile regex: empty (sub)expression

Yes, that's also correct.  Zsh patterns are not regexes and the default
regex library doesn't allow that syntax.  I believe you can use that
syntax if you load the zsh/pcre module and setopt REMATCH_PCRE.



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