tags:

views:

67

answers:

1

I'm looking for a function which will try to find and return whatever was matched by the regular expression \\(\\S-\\) and probably nil if nothing was found. The search should start from (point) and search to the end of the document.

+6  A: 

Use re-search-forward and match-string:

(when (re-search-forward "\\(\\S-\\)" nil t)
  (match-string 1))

If you don't want point to move, wrap it in a save-excursion:

(save-excursion
  (when ...
scottfrazer