1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
|
# File 'lib/textbringer/buffer.rb', line 1116
def re_search_backward(s, raise_error: true, count: 1)
if count < 0
return re_search_forward(s, raise_error: raise_error, count: -count)
end
re = new_regexp(s)
pos = @point
count.times do
p = pos
begin
i = byteindex(false, re, p)
if i.nil?
if raise_error
raise SearchError, "Search failed"
else
return nil
end
end
p = get_pos(p, -1)
rescue RangeError
if raise_error
raise SearchError, "Search failed"
else
return nil
end
end while match_end(0) > pos
pos = match_beginning(0)
end
goto_char(pos)
end
|