regex - Regular Expression to find whitespaces and replace with a dash -
regex - Regular Expression to find whitespaces and replace with a dash -
i thought might work: ^['\s+', '-', "this should connected"\w\s]{1,}$
but wrong it. no of regex place dashes between words while @ same time not placing dashes in front end of first word or behind lastly word?
i need maintain in mind don't want dash before first word or after lastly word. and, have 1 word no dashes required.
the syntax utilize rather strange. why utilize ^
, $
anyway?
one can utilize next regex:
s/\s+/-/g
s
means substitute occurence. g
means global: matches should replaced.
using tool sed
or perl
.
example sed
:
sed -r 's/\s+/-/' < file
regex
Comments
Post a Comment