Here is my expression:
(setq myregexp (rx bol
"####"
(one-or-more anything)
"."))
This should match any string starting with "####", spanning over zero or mode new lines, and stop at the first found "." right?
This is my test buffer:
#### This.
#### This too.
#### And also
this.
#### Oh, and this too.
But not this.
And here is the fn that I use to test it:
(defun regtest ()
"search"
(interactive)
(save-excursion
(while
(re-search-forward myregexp nil t nil)
(message "Found [%s] and [%s]" (match-string 0) (match-string 1)))))
But here is what it returns:
Found [#### This.
#### This too.
#### And also
this.
#### Oh, and this too.] and [nil]
How can I make the regexp stop at the first found match of the last rx
expression? And more generally, how to properly use anything
?
minimal-match
worked ; you should make it an answer so I can accept it ; it's a big deal, I mean, that was my last gripe aboutrx.el
and I think everybody wants to know about this one, you do realize there is no rx.el documentation apart from the very lib header? :) Thanks! – yPhil Aug 23 '17 at 15:35C-h f rx
? – Erik Aug 26 '17 at 17:05