我有一个这样的字符串:
group1
Members:
m/a
m/b
group2
Members:
m/c
m/d
m/e
group3
No Members
我想要一个像这样的扫描结果:
[["group1","a","b"],["group2","c","d","e"],["group3"]]
但我可以拥有:
[["group1","a"],["group2","c"],["group3", nil]]
使用这个正则表达式:
text.scan(/([^\r\n]+)\r?\n[\s\t]*(?:No |)Members[\s:]*\r?\n(?:[\t\s]*m\/(\w+)+\r?\n)*/m)
我可以只用 regexp 做我想做的事吗?