while read line; do
outline=""
for i in $line; do
case $i in
"[["*) i=$(echo $i |sed 's/\([a-z]\)\([A-Z0-9]\)/\1 \2/g') ;;
esac
outline="$outline $i"
done
echo ${outline# }
done<infile
---------- Post updated at 08:53 AM ---------- Previous update was at 08:42 AM ----------
echo '[[HelloInCapitals]] OrAnd [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' | sed 's/[A-Z]/ &/g; s/\[ /\[/g'
[[Hello In Capitals]] Or And [[Pharmaceutical Society Of Great Britain V Boots1952]]
$ echo '[[HelloInCapitals]] OrAnd [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' | perl -pe's/\B(?:[[:upper:]]|\d+)\B/ $&/g'
[[Hello In Capitals]] Or And [[Pharmaceutical Society Of Great Britain VBoots 1952]]
This should also take care for the numbers, if you want to process only words. For lines including words within double square brackets use one of those solutions above.
sed 's/[A-Z]/ &/g; s/[0-9][0-9]*/ &/g; s/\[ /\[/g'
zsh-4.3.10[t]% print '[[HelloInCapitals]] AndOr [[PharmaceuticalSocietyOfGreatBritainVBoots1952]]' |
perl -pe'
s/\Q[[\E(.*?)\Q]]\E/($x=$1)=~s#\B([[:upper:]]|\d+)\B# $1#g;"[[".$x."]]"/eg
'
[[Hello In Capitals]] AndOr [[Pharmaceutical Society Of Great Britain V Boots 1952]]
---------- Post updated at 03:17 PM ---------- Previous update was at 03:15 PM ----------