Nokogiri - 在两个 " 之间选择 link
Nokogiri - Selecting a link between two " s
我在选择作为嵌入代码一部分的 link 时遇到问题。它在两个 "
之间。我已将 link 放入我正在尝试的代码中。
谢谢。
正确的形式是。
(?<=")(.*)(?=")
输入:
"https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt"
输出:
https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt
Ruby代码:
re = /(?<=")(.*)(?=")/m
str = '"https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt"'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
我在选择作为嵌入代码一部分的 link 时遇到问题。它在两个 "
之间。我已将 link 放入我正在尝试的代码中。
谢谢。
正确的形式是。
(?<=")(.*)(?=")
输入:
"https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt"
输出:
https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt
Ruby代码:
re = /(?<=")(.*)(?=")/m
str = '"https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt"'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end