【发布时间】:2012-10-11 05:08:44
【问题描述】:
我在 elisp 中工作,我有一个代表项目列表的字符串。字符串看起来像
"apple orange 'tasty things' 'my lunch' zucchini 'my dinner'"
我正在尝试将其拆分为
("apple" "orange" "tasty things" "my lunch" "zucchini" "my dinner")
This is a familiar problem。我解决它的障碍不是关于正则表达式,而是更多关于 elisp 的细节。
我想要做的是像这样运行一个循环:
-
(while (< (length my-string) 0) do-work)
do-work 在哪里:
- 将正则表达式
\('[^']*?'\|[[:alnum:]]+)\([[:space:]]*\(.+\)应用于my-string - 将
\1附加到我的结果列表中 - 将
my-string重新绑定到\2
但是,我不知道如何让 split-string 或 replace-regexp-in-string 做到这一点。
如何将此字符串拆分为可以使用的值?
(或者:“我还没有找到哪个内置的emacs函数呢?”)
【问题讨论】: