Replacing the character by deli meter based on length in SED script
I want to achieve following things in sed script. I tried with greedy operator it does not works as i expected. for reference
:loop
s#\(S\)\(.\)\(.*R\)#-\n\1\3\n#
t loop
s#SR#--#
s#\n##g
If the pattern has FlowerR this should be replaced by number -------
If the pattern hash FoR this should be rep开发者_如何转开发laced by ---
So the number replace character is equal to matched pattern length which between F and R
$ echo "a FloweR has FaR FeweR FlaiR" | perl -pe 's{F.*?R}{"-" x length $&}eg'
a ------ has --- ----- -----
精彩评论