SyntaxFix
Write A Post
Hire A Developer
Questions
Using bash regex capabilities:
re="^([^-]+)-(.*)$" [[ "ABCDE-123456" =~ $re ]] && var1="${BASH_REMATCH[1]}" && var2="${BASH_REMATCH[2]}" echo $var1 echo $var2
OUTPUT
ABCDE 123456