已关闭,该问题需要details or clarity,目前不接受回答。
**想要改进此问题?**通过editing this post添加详细信息并澄清问题。
16天前关闭
Improve this question
我有一些文字问题的题库.他们需要重新格式化,我不能找出正则表达式移动反馈之间的问题和答案的选择.反馈以“@”开始. * 表示正确的答案.最初的反馈是只有一个正确的答案,但是我们的新LMS只支持对任何不正确答案的一般反馈。2我如何将反馈文本后面的@移动到第一个答案选项之前?
32) This is the question text. This is the question text. This is the question text. This is the question text. This is the question text. This is the question text. This is the question text. This is the question text. This is the question text. This is the question text.
*a. 091°.
@ (Chapter - Section)
This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback. This is the feedback.
b. 095°.
c. 099°.
1条答案
按热度按时间yhqotfr81#
你可以通过使用正则表达式
^(\d+\).*\n\n)((?:\*?[a-z]\. .*\n)*)(@ .*\n.*\n)((?:\*?[a-z]\. .*\n)*)
和替换字符串$1$3\n$2$4
来实现。这里regex的意思是:
^(\d+\).*\n\n)
行,以数字开头,结束方括号和空格,后跟两个新行,((?:\*?[a-z]\. .*\n)*)
行,以可选的*
、字母、点和任何数量的任何符号开始,重复任何次数。任何数量的答案。(@ .*\n.*\n)
两行,第一行从@
开始(反馈)((?:\*?[a-z]\. .*\n)*)
和以前一样。替换的演示可以在here中看到。在那里你可以修改替换字符串,因为你没有提供足够的输入来可靠地猜测期望的输出。
要使用此功能,请使用类似于VScode或Sublime Text的内容打开文件:
打开替换视图Ctrl+H
确保启用了选项
Use regular expression
。粘贴正则表达式和替换字符串。
替换所有Ctrl+Alt+Enter
EDIT:考虑多行反馈