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

parameter expansion with '$'



Hi,

Consider this example:

$ X=abc
$ echo ${X/c/}
ab

However, I'd like to only perform the substitution when 'c' occurs at the
end of the string:

$ echo ${X/c$/}
abc  # I'd like this to return 'ab' like above

I assume others see the same results? Can anybody help me understand why it
doesn't work, and how I can interpret the '$' as a regular expression
wildcard rather than some other sort of zsh sigil?

Thanks,
Kartik
zsh 5.0.5 on x86_64 with extendedglob


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