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

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -