R
RichardOnRails
Hi,
I'm trying to use Ruby REs to transform Windows addresses into HTML
anchors.
CODE:
DEBUG = 1
fo= File.open("Microsoft EXEs xformed.txt", "w")
fi= File.new("Microsoft EXEs.txt")
fi.each { |line|
next unless line =~ /11/
p "1: " + line if DEBUG
line.sub!( /^(.*\\)(\w+\.\w+)$/i, '<p><a HREF="\1\2"> \2 </a></p>')
p "2: " + line if DEBUG
line.sub!(/(HREF=")/, '\1file:\\\\\\')
p "3: " + line if DEBUG
fo.write(line)
}
fi.close
fo.close
OUTPUT (in Sci/TE
"1: F:\\Program Files\\Microsoft Office\\Visio11\\VISIO.EXE\n"
"2: <a HREF=\"F:\\Program Files\\Microsoft Office\\Visio11\\VISIO.EXE
\"> VISIO.EXE </a><br>\n"
"3: <a HREF=\"file:\\\\F:\\Program Files\\Microsoft Office\\Visio11\
\VISIO.EXE\"> VISIO.EXE </a><br>\n"
[snip]
Note that output displayed within Sci/TE has all backslashes and
quotes escaped with prefixed backslashes.
QUESTION 1:
Displayed line 3 appears to have only two escaped backslashes at the
start of the HREF address.
However my 2nd substitution supplies three escaped backslashes.
Furthermore, the 1st line of the output file confirms that only two
backslashes were inserted.
Can you see any reason for not getting all three backslashes specified
in the RE?
QUESTION 2:
This question may be inappropriate for this newsgroup, so please
ignore it unless you care to answer it.
Happily, the two slashes generated above were sufficient for Firefox
3 running over WinXP-Pro/SP3 to recognize that the HREF referred to a
local file. (I thought I need three slashes for that.)
However, Firefox (I guess) blocked the execution of it and offered
only to save it. I'm running under Admin privileges on my own home
machine. Is there anyway for me to the Windows program launched?
Thanks in Advance,
Richard
I'm trying to use Ruby REs to transform Windows addresses into HTML
anchors.
CODE:
DEBUG = 1
fo= File.open("Microsoft EXEs xformed.txt", "w")
fi= File.new("Microsoft EXEs.txt")
fi.each { |line|
next unless line =~ /11/
p "1: " + line if DEBUG
line.sub!( /^(.*\\)(\w+\.\w+)$/i, '<p><a HREF="\1\2"> \2 </a></p>')
p "2: " + line if DEBUG
line.sub!(/(HREF=")/, '\1file:\\\\\\')
p "3: " + line if DEBUG
fo.write(line)
}
fi.close
fo.close
OUTPUT (in Sci/TE
"1: F:\\Program Files\\Microsoft Office\\Visio11\\VISIO.EXE\n"
"2: <a HREF=\"F:\\Program Files\\Microsoft Office\\Visio11\\VISIO.EXE
\"> VISIO.EXE </a><br>\n"
"3: <a HREF=\"file:\\\\F:\\Program Files\\Microsoft Office\\Visio11\
\VISIO.EXE\"> VISIO.EXE </a><br>\n"
[snip]
Note that output displayed within Sci/TE has all backslashes and
quotes escaped with prefixed backslashes.
QUESTION 1:
Displayed line 3 appears to have only two escaped backslashes at the
start of the HREF address.
However my 2nd substitution supplies three escaped backslashes.
Furthermore, the 1st line of the output file confirms that only two
backslashes were inserted.
Can you see any reason for not getting all three backslashes specified
in the RE?
QUESTION 2:
This question may be inappropriate for this newsgroup, so please
ignore it unless you care to answer it.
Happily, the two slashes generated above were sufficient for Firefox
3 running over WinXP-Pro/SP3 to recognize that the HREF referred to a
local file. (I thought I need three slashes for that.)
However, Firefox (I guess) blocked the execution of it and offered
only to save it. I'm running under Admin privileges on my own home
machine. Is there anyway for me to the Windows program launched?
Thanks in Advance,
Richard