28 lines
655 B
Ruby
28 lines
655 B
Ruby
|
|
#! /bin/ruby
|
||
|
|
|
||
|
|
lines = File.readlines("input")
|
||
|
|
|
||
|
|
File.open("output", "w") { |file|
|
||
|
|
#file.write("adding first line of text")
|
||
|
|
lines.each do |line|
|
||
|
|
if line.length == 1 then
|
||
|
|
file.puts()
|
||
|
|
else
|
||
|
|
start = line.index('\'')+1
|
||
|
|
finish = (line.length) - 4
|
||
|
|
subs = line[start..finish].to_s
|
||
|
|
newSubs = subs.gsub(/(.{1})(?=.)/, '\1 \2')
|
||
|
|
newSubs2 = ''
|
||
|
|
newSubs.split('').each do |ch|
|
||
|
|
if ((ch >= 'A' and ch <= 'Z') or (ch>= 'a' and ch<= 'z') or (ch == ' ')) then
|
||
|
|
newSubs2 = newSubs2 + ch
|
||
|
|
else
|
||
|
|
newSubs2 = newSubs2 + '\'' + ch + '\''
|
||
|
|
end
|
||
|
|
end
|
||
|
|
newLine = line[0..start-2] + newSubs2 + ';'
|
||
|
|
file.puts(newLine)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
}
|