D
Domingo Alvarez Duarte
I have been using strscan till version 0.65 and it was working with a
code like this but now trying to upgrade to ruby 1.8 it doesn't, is
there a bug in strscan or I misunderstood it ?
I expect to find a match for the regular expression but it doesn't.
#---- code start here
require 'strscan'
SSI_search_re = /<!--#(.+?)#-->|\[\)(.+?)\(\]/m
def parse(html)
ret_var = ''
ssc = StringScanner.new(html)
ret_var << "\n0print(' xxx start scanner zzz ')\n"
while ssc.scan(SSI_search_re) do
ret_var << "\n1print([}#{ssc.pre_match}{])\n"
if ssc[1]
ret_var << ' :: ' + ssc[1]
else
ret_var << "\n2print(#{ssc[2]})\n"
end
end
ret_var << "\n3print([}#{ssc.rest}{])\n"
ret_var << "\n4print(' vvv end scanner kkk ')\n"
end
res = parse('<html><!--# . vvvvcartasvvvv . #--><body>Hello
[)Domingo(] !</body></html>')
puts res
#---- code end here
code like this but now trying to upgrade to ruby 1.8 it doesn't, is
there a bug in strscan or I misunderstood it ?
I expect to find a match for the regular expression but it doesn't.
#---- code start here
require 'strscan'
SSI_search_re = /<!--#(.+?)#-->|\[\)(.+?)\(\]/m
def parse(html)
ret_var = ''
ssc = StringScanner.new(html)
ret_var << "\n0print(' xxx start scanner zzz ')\n"
while ssc.scan(SSI_search_re) do
ret_var << "\n1print([}#{ssc.pre_match}{])\n"
if ssc[1]
ret_var << ' :: ' + ssc[1]
else
ret_var << "\n2print(#{ssc[2]})\n"
end
end
ret_var << "\n3print([}#{ssc.rest}{])\n"
ret_var << "\n4print(' vvv end scanner kkk ')\n"
end
res = parse('<html><!--# . vvvvcartasvvvv . #--><body>Hello
[)Domingo(] !</body></html>')
puts res
#---- code end here