'Zsh oneliner to Extract part of string until and including token
I need a solution in zsh
I have a string like http://xxx.abc.mp3?yyy:mno. Is there a one-liner in zsh that can extract the string until mp3, that http://xxx.abc.mp3? I can do this in bash, but I needed a way to do it in zsh.
Solution 1:[1]
You didn't say how you did it in bash, but the same substitution works with both shells:
str='http://xxx.abc.mp3?yyy:mno'
printf "%s\n" "${str/%\?*}"
Removes the text that matches a question mark and 0 or more characters until the end of the string.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Shawn |
