0

I am doing (bounds-of-thing-at-point 'word) to capture words in a buffer.

(let* ( (bounds  (bounds-of-thing-at-point 'word))
         (word   (buffer-substring (car bounds) (cdr bounds)))

I then match the word with a regexp, either frontally, medially, or posteriorly.

"\\<\\([Ee]xt[ei]r\\|[Ee]ntr[aeiu]\\)"

"\\([[:alpha:]]+\\)\\(p[ai]ra\\|peri\\)\\([[:alpha:]]+\\)"

"\\([eu]ckle\\|[ai]cle\\|ical\\)\\>"

I want to allow the possibility for words to include hyphens (-) and punctuation.

As examples, the following are mentioned: (real-, short-time-Fourier-transformation, "wavelet footprints".

From some tests I have done, it seems that the captured words using bounds-of-thing-at-point disregards hyphens (-) and punctuation.

I am concluding that I do not have to include any punctuation in my string regexp, and can safely neglect [[:punct:]]? in the following regexp.

"\\([[:alpha:]]+[-]?\\)ple\\([[:alpha:]]+[[:punct:]]?\\)"

Is my general assessment of not requiring the use of [[:punct:]]? in my regexp correct?

1
  • I don't understand your logic. You say that you 'want to allow the possibility for words to include hyphens (-) and punctuation'. Why you do not ask how to 'capture' the full words (i.e. symbols)? Aug 22, 2022 at 2:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.