ruby - Regex .* expression extracts only a part of the characters I want to extract? -


i have string:

rder=3d"0" width=3d"650">=0d=0a <tr>=0d=0a <td valign=3d"top">=0d=0a <p>=0d=0a <strong>hi mike tyson</strong>,<br/>=0d=0a = 

i want extract mike tyson string. name same in above string, first clue use regex:

[^rder=3d"0" width=3d"650">=0d=0a <tr>=0d=0a <td valign=3d"top">=0d=0a <p>=0d=0a <strong>hi ].*[^<\/strong>,<br\/>=0d=0a =] 

however, outputs mike ty instead of mike tyson. ideas?

the square brackets make entire match character class

this expression match mike tyson

(?<=rder=3d"0" width=3d"650">=0d=0a <tr>=0d=0a <td valign=3d"top">=0d=0a <p>=0d=0a <strong>hi ).*?(?=<\/strong>,<br\/>=0d=0a =)

live example: http://www.rubular.com/r/oak2zmbsph


Comments