J
Jim Burgess
I have a string:
course_info =
"<course><date>10.10.09<date><title>Maths</title></course>"
I want to use a reg ex to extract the title from the string, in this
case "Maths"
So far I came up with:
course_info.gsub!(/^(.*)<title>/, "")
course_info.gsub!(/<\/title>(.*)$/, "").chomp!
p course_info
# -> "Maths"
Is it possible amalgamate these two regular expressions into one or to
improve this in any way?
Am grateful for any help.
course_info =
"<course><date>10.10.09<date><title>Maths</title></course>"
I want to use a reg ex to extract the title from the string, in this
case "Maths"
So far I came up with:
course_info.gsub!(/^(.*)<title>/, "")
course_info.gsub!(/<\/title>(.*)$/, "").chomp!
p course_info
# -> "Maths"
Is it possible amalgamate these two regular expressions into one or to
improve this in any way?
Am grateful for any help.