#!/bin/bash
# your code goes here

part='\| \$ ; * ( $'

string="noquote $part \`hostname\` \"doublequote $part \`hostname\`\" 'singlequote $part \`hostname\`'"

#string="\\a jk \"\\a jk\" '\\a jk'"		# \ as first char
#string="a\\ jk \"a\\ jk\" 'a\\ jk'"		# \ on space
#string="a j\\k \"a j\\k\" 'a j\\k'"		# \ mid string 
#string="a jk \"a jk\\\" 'a jk\\' \\"		# \ as last char

pattern='s/[][`~!@#$%^&*():;<>.,?/\|{}=+-]/\\&/g' #;s/\\(.)/\1/g'

# within single quotes do nothing, not neccesary, as in, don't apply the pattern at all  
# within double quotes remove \ if the following char is in list but not another \

echo "$string"
echo "$string" | sed "$pattern"
declare -a "array=($( echo "$string" | sed "$pattern" ))"
for arg in "${array[@]}"; do echo "$arg"; done 
