#!/bin/bashs='/word1 /word2 //word3'perl -pe 's~(?<!/)/(?!/)~ ~g' <<< "$s"sed -E 's~(^|[^/])/($|[^/])~\1\n\2~g;s//\1\n\2/g;s/\n/ /g' <<< "$s"
Standard input is empty
word1 word2 //word3 word1 word2 //word3
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!