I am working on a text editor in ruby, and I need to support the Find feature using user-supplied regular expression patterns. Here is a simple (familiar) use case:
Joe A user edits a text file and positions the cursor somewhere in the middle of the file. He wants to search back from the current cursor location for the nearest substring matching an arbitrary regular expression.
I think this problem is applying the user pattern to the entire line preceding the cursor location in the file. Of course, I could iterate over all matches from the beginning of the file and use the last match, but it seems painfully inefficient ... It would be better to look from right to left, but I did not find a way to do this with the Regexp ruby. You can help?
ruby regex reverse
joshng
source share