re = /(?<txt_pre_linka>\w+)?(?<ceo_link><a .*?>.*?<\/a>)(?<txt_after_linka>.*?)(?=<a .*?>.*?<\/a>|$|\.)/
str = 'ECSE-4530 Digital Signal Processing
Rich Radke, Rensselaer Polytechnic Institute
Lecture 5: the Fourier Transform (9/11/14)
shsdhsh<a class="yt-simple href="/watch?v=5HSn3DPHQcQ&t=2s">0:00:02</a> The Fourier Transform.
Shshshsh<a class="yt-simple" href="/watch?v=5HSn3DPHQcQ&t=219s">0:03:39</a> Thinking ofles of a function
shgshshshs<a class="yt-simple" href="/watch?v=5HSn3DPHQcQ&t=463s">0:07:43</a> Derivim aiod goes to infinity'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html