2017-02-06 4 views
-3

삽입 된 코드의 일부인 링크를 선택하는 데 문제가 있습니다. 그것은 두 &quot 사이입니다. 나는 노력하고있는 코드에 대한 링크를 넣었다.Nokogiri - 두 개의 링크를 선택하는 중

감사합니다.

https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt

+1

링크 된 페이지와 "[mcve]"를 포함하여 "[ask]"를 읽으십시오. 최소 입력 데이터 및 예상 출력과 함께 문제 자체를 설명하는 최소 코드가 있어야합니다. 링크 썩은 다음 휴식 시간과 그들이 할 때 질문은 의미가 없을 것입니다. –

답변

1

올바른 양식입니다.

(?<=&quot;)(.*)(?=&quot;) 

입력 :

&quot;https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt&quot; 

출력 :

https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt 

루비 코드 :

re = /(?<=&quot;)(.*)(?=&quot;)/m 
str = '&quot;https://gist.githubusercontent.com/anonymous/d2efee7b3967debc531d67de9cc7993a/raw/3f5e0e63ce6fe3aa4cffc2d0afafd2415408308a/gistfile1.txt&quot;' 

# Print the match result 
str.scan(re) do |match| 
    puts match.to_s 
end 

시험 코드 : http://ideone.com/moljMo

참조 : https://regex101.com/r/vrBUhc/1