I want to omit the beginning of words starting with some
(e.g. something
changed to thing
).
This is the way I am doing it
(insert (replace-regexp-in-string "\\<\\(some\\)" "" word))
Is this the way to do this? Can it be simplified? do I require to have \\(
and \\)
?
word
is somehow obtained from the current buffer, then getting it (however you get it), doing the replacement in the string and then inserting the resulting string is much slower than doingreplace-regexp
in the buffer directly. I did a simple test with two functions: one that did areplace-regexp
on the whole buffer and one that got each word, and did theinsert/replace-regexp-in-string
you show above. I then ran the two functions on a file that contained 1000something
s: the whole-buffer fimplementation was almost 100 times faster (4 msec vs 370 msec).replace-regexp
can be limited to a region.replace-regexp
.