Occurances

faithless1
faithless1 used Ask the Experts™
on
Hello,

I'm looking for a to add spaces (before and after) if there is a match by specifying specific words.

example
wentstorenow

output

went store now


I already have a script that takes a file as input, but I'm looking for a way where I can specify words directly on the command line.

Thank you.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2014
Top Expert 2015
Commented:
perl -pe 'BEGIN{$re=qr/@{[join"|",splice @ARGV]}/}s/($re)/ $1 /g' store <<END
wentstorenow
END

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial