Searching with regular expressions
This ZIP file contains two demo projects.
1) Search from the cursor position
2) Search and highlight all occurrences
The both demo projects use the same technique. They save content to a sting that has 1:1 correspondence to the original content. Regular expressions are searched in this string using TRegEx. After finding, they are marked in the original document.
This demo requires Delphi XE or newer (because TRegEx was introduced in this version of Delphi).
The first version of this demo is very fast even for huge documents.
The second version may be slow, because TRegEx.Matches is slow if it returns a large count of matches (in real application, you can use TRegEx.Match and then a cycle of Match.NextMatch, and limit a count of results).
For results highlighting, the second demo uses the same mechanism as for live spelling checking (instead of wavy underlines, it draws semitransparent color rectangles).
[Demo] Searching with regular expressions
-
- Site Admin
- Posts: 14313
- Joined: Sat Aug 27, 2005 10:28 am
- Contact: