如何将只包含在{}中的单个单词从文本中提取出来
an example of the text {Creating|Making|Producing} blah blah blah或
another example of the text {{In order to|As a way to|So that you can|To be able to} {connect|link|join}} blah blah blah以我有限的判断力,我已经走到了这一步
text.scan(/{([^}]*)}/)[0][0].split('|')但是这会选择文本{In order to|As a way to|So that you can|To be able to并像{In order to那样拆分它
如何仅在{}中选择文本
预期产出
["In order to", "As a way to", "So that you can", "To be able to"]谢谢!
发布于 2014-04-29 10:31:45
尝试:
text.scan(/{([^{}]*)}/)[0][0].split('|')https://stackoverflow.com/questions/23361937
复制相似问题