For example i have lines:
* test1
** another tests
* some other line
I would like to match t
in first line, a
in second, s
in third.
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.
Sign up to join this communityFor example i have lines:
* test1
** another tests
* some other line
I would like to match t
in first line, a
in second, s
in third.
(re-search-forward "[^*[:space:]]")
Then use match-data
or similar functions, if you want the match.
And put that code inside save-excursion
if you don't want to end up moving the cursor.
If you want to include newline chars as whitespace chars then use something like
"[^*[:space:]\n]"
Emacs regexps don't have arbitrary zero-width look-around assertions, so if you're hoping for a pattern which in its entirety would only ever match those characters (no matter where it started from, or how many times you searched) then you're out of luck. In Emacs such behaviours are achieved using elisp rather than solely with the regexp engine.
You can, of course, search for:
^\*+ \(.\)
aka
"^\\*+ \\(.\\)"
And then you'll have the character you wanted in the matched sub-group.
It all depends on what you're doing, though.