Re: [问题] 关于单选题问卷 该如何处里

楼主: PurpleCrow (17868)   2011-08-09 22:56:59
※ 引述《godspeedlee (妳,我可以)》之铭言:
: ※ 引述《chrisdar (克里斯)》之铭言:
: : 现在我有一系列单选题问卷如下
: : (Q1) Question 1
: : (1)[ ] Answer 1 for Question 1
: : (2)[ ] Answer 2 for Question 1
: : (3)[*] Answer 3 for Question 1
: : (4)[ ] Answer 4 for Question 1
: : (Q2) Question 2
: : (1)[ ] Answer 1 for Question 2
: : (2)[ ] Answer 2 for Question 2
: : (3)[ ] Answer 3 for Question 2
: : (4)[ ] Answer 4 for Question 2
: : (Q3) Question 3
: : (1)[*] Answer 1 for Question 3
: : (2)[ ] Answer 2 for Question 3
: : (3)[*] Answer 3 for Question 3
: : (4)[ ] Answer 4 for Question 3
: : (Q4) Question 4
: : (1)[*] Answer 1 for Question 4
: : (2)[ ] Answer 2 for Question 4
: : (3)[ ] Answer 3 for Question 4
: : (4)[ ] Answer 4 for Question 4
: : Pattern : \(Q(\d+)\).*?\((\d+)\)\[\*\]
: : 现在问题出在
: : 1. Q2 因为没有作答 导致把 Q3 的答案带到 Q2 去
: : 2. Q3 重复作答也无法排除
: : 可否提供一些思考方式或做法 谢谢
: 分成两次来作比较轻松:
: 第一步: 将每个 Question 切割成单独的区块
: \(Q\d+\)[\s\w]+(\(\d+\)\[[\s*]\][\s\w]+)+
: 或
: (?<=\(Q\d+\))(.*?)(?=\(Q\d+\))
这个式子会漏掉
(Q4) Question 4
(1)[*] Answer 1 for Question 4
(2)[ ] Answer 2 for Question 4
(3)[ ] Answer 3 for Question 4
(4)[ ] Answer 4 for Question 4
: 第二步: 对每个区块个别进行搜寻
: \(\d+\)\[\*\][\s\w]+
(Q3) Question 3 依然无法排除 得
(1)[*] Answer 1 for Question 3
(3)[*] Answer 3 for Question 3
: 当然,使用 regexp 常常会有一种冲动想一次解决 :P
这个题目跟一次解决或分次解决没有关系
重点在于有复数个*的无效状况无法排除

Links booklink

Contact Us: admin [ a t ] ucptt.com