rx 매크로로 S식을 써서 정규식을 만들 수도 있어요.
그 예제는 (rx "text" (group "pattern"))가 돼요
rx가 어떻게 동작하는지 보여 주는 다음 예제들은 rx.el의 주석에서 가져왔어요:
^;;\\s-*\n\\|^\n라는 식은
이렇게 바뀌어요
(rx (or (and line-start ";;" (0+ space) ?\n)
(and line-start ?\n)))
[ \t\n]*:\\([^:]+\\|$\\)라는 식은
이렇게 바뀌어요
(rx (and (zero-or-more (in " \t\n")) ":"
(submatch (or line-end (one-or-more (not (any ?:)))))))
영어에서 번역·원문 보기You could build the expressions as sexps with the rx macro instead.
That example would read (rx "text" (group "pattern"))
To illustrate how rx behaves, these additional examples come from rx.el's commentary:
The expression ^;;\\s-*\n\\|^\n
turns into
(rx (or (and line-start ";;" (0+ space) ?\n)
(and line-start ?\n)))
The expression [ \t\n]*:\\([^:]+\\|$\\)
turns into
(rx (and (zero-or-more (in " \t\n")) ":"
(submatch (or line-end (one-or-more (not (any ?:)))))))