New answers tagged

1

I will give the same answer as @Drew, but phrased a little differently. Your expression 《.+IJ》will match the first 《, then will match the minimum number of characters (because of the ?) until the IJ》 sequence. You cannot use the "non-greediness" of the ? to un-match the first matching 《 in order to find a later one. An expression you can use to do what ...


5

The problem is not about using non-greedy matching. It is about which chars you're matching. Specifically, you want to match 《 followed by any number of non-《 chars, followed by IJ》. This is a regexp that finds that: 《[^《]+IJ》. This is a typical operation, for searching text that has paired delimiters. For example, you do the same thing when searching ...


2

You'll want to use the function buffer-substring-no-properties. In the documentation for M-x describe-function buffer-substring it says this: This function copies the text properties of that part of the buffer into the result string; if you don’t want the text properties, use buffer-substring-no-properties instead.


3

You can simulate the \ze construct using repeated matching. See also (info "(elisp) Search-based Fontification"). (defun my-matcher (limit) (when (re-search-forward "\\([0-9]\\{1,3\\}\\)\\(?:[0-9]\\{6\\}\\)*\\(?:[0-9]\\{3\\}\\)\\_>" limit t) (goto-char (match-beginning 1)) (re-search-forward "[0-9]+" (match-end 1)))) (font-lock-add-...


Top 50 recent answers are included