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

Re: backreferences



On 10/16/2015 08:33 PM, Bart Schaefer wrote:

Only seems to. Try sstring="edcbaabcdeedcbaabcde" and I don't think you'll get the result you expected.

Correct. It fails if the very start of the string is the negation, which seems strange. Any change at all to the 'bait' leading 'edcba' fixes it. The empty string is the intuitive expectation for match[1].
This needs to be (#b)(^edcba*)(edcba)(*)
... and that does indeed seem to cover every situation that I've tried. Am I correct in reading the '*' as saying: "Anything OR NOTHING in front of 'edcba' "? That's not hard to fathom. Anyway I guess the difference is something that could be put to use in some conceivable situation. BTW does sed have that functionality? I did quite a bit of research and came up with nothing. Even at StackExchange no one had an answer, but it seems to me like a very fundamental sort of thing. Cool if zsh can do something that sed can't tho you'd hardly expect that to be the case.
There might be something in the Bash to Zsh book -- I don't have it handy to confirm.
Nope, nothing that I can find.



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