Is there a native Emacs Lisp function that behaves like strpos() in PHP? It should return the position of first occurrence of the given string in current buffer. Function search-forward is nice, but it modifies the character position.
Is there a native Emacs Lisp function that behaves like strpos() in PHP ?
Share
You can do:
or
But those calls make a copy of the string, which isn’t practical. A better solution would be to use this:
It also depends on what you want to do after finding the position. The documentation for match data might be useful. If you want to use the
match-dataafterwords, remove the call to'save-match-data.