I can not figure it out:
22.584\r\n\t\t\tl-6.579-22
I want to match "\r\n\t\t\t" and replace it with a single space " " . The problem is the number of "\t" , "\r" and "\n" , as well as surrounding characters.
"\r\n\t\t\t"
" "
"\t"
"\r"
"\n"
Help!
s/\s+/ /g div>
s/\s+/ /g
s/(?:\\[rnt])+/ /g
In PHP:
preg_replace("/(?:\\\[trn])+/", " ", $str);
sed 's/\\[rnt]/ /g;s/ */ /g'
'22.584\r\n\t\t\tl-6.579-22'.gsub(/(\\[rnt])+/, ' ')
#!/usr/bin/ruby1.8 s = "22.584\r\n\t\t\tl-6.579-22" ps # => "22.584\r\n\t\t\tl-6.579-22" p s.gsub(/[\r\n\t]+/, ' ') # => "22.584 l-6.579-22"
I would consider CR-NL as one atom:
str.gsub!(/(?:\r\n)+\t+/, ' ')