var_bash2.tests 505 B

123456789101112131415161718192021222324
  1. var=abc123dcba123
  2. echo ${var/d/x}
  3. echo ${var/c/x}
  4. echo ${var//c/x}
  5. echo ${var/[123]/x}
  6. echo ${var//[123]/x}
  7. echo ${var/c*/x}
  8. echo ${var/*c/x}
  9. # must match longest match: result is "abx23"
  10. echo ${var/c*1/x}
  11. # empty replacement - 2nd slash can be omitted
  12. echo ${var/[123]}
  13. echo ${var//[123]}
  14. ### ash doesn't support
  15. ### # match only at the beginning:
  16. ### echo ${var/#a/x}
  17. ### echo ${var/#b/x} # should not match
  18. ### echo ${var//#b/x} # should not match
  19. ### # match only at the end:
  20. ### echo ${var/%3/x}