42 lines
561 B
Ruby
Executable File
42 lines
561 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
str1 = %Q!lbl: dc "Hallo", ", ", 0, 1, " der","Jens"!
|
|
|
|
i=0;
|
|
|
|
def get_stri_lit (str)
|
|
res = [""];
|
|
state = "out"
|
|
|
|
j = 0;
|
|
k = 0;
|
|
for i in (0..str.length-1)
|
|
c = str[i];
|
|
nstate = state
|
|
case state
|
|
when "out"
|
|
if c == "\""[0]
|
|
nstate = "in"
|
|
end
|
|
when "in"
|
|
if c == "\""[0]
|
|
nstate = "out"
|
|
if j > 0
|
|
k = k + 1;
|
|
res[k] = ""
|
|
end
|
|
else
|
|
res[k] = res[k] + format("%c", c);
|
|
j = j + 1;
|
|
end
|
|
end
|
|
state = nstate
|
|
end;
|
|
return res
|
|
end
|
|
|
|
get_stri_lit(str1).each do |word|
|
|
puts word
|
|
end
|
|
|
|
|