我有一个从后端服务器获取的数组。但我想使用' ul将该数组转换为Dim _inputStr As String = "D7"
Dim _isCorrectHex As Boolean = Text.RegularExpressions.Regex.Match(_inputStr, "^([0-9a-fA-F]+)$").Success
。如何使用list
清理数组并将它们转换为单个清除数组?
这是我得到的数据:
regexp
结果应该是:(对于休息而言,标记为[
"1. Submittals in progress\n2. Structural works in progress in S2 & S3\n3. Structural works in progress in N4.\n4. Childrens Mall pedestal and steel fabrication.",
"",
"1. Procurement of activities in progress.\n2. External works for mist pool in progress\n3. MEP 1st & 2nd fix in progress\n4. Block work and grade slab in progress "
]
。在2个数组之间也是\n
字符串。
empty
答案 0 :(得分:3)
假设这是输入:
arr=[
"1. Submittals in progress\n2. Structural works in progress in S2 & S3\n3. Structural works in progress in N4.\n4. Childrens Mall pedestal and steel fabrication.",
"",
"1. Procurement of activities in progress.\n2. External works for mist pool in progress\n3. MEP 1st & 2nd fix in progress\n4. Block work and grade slab in progress "
]
您可以使用以下方式获取输出数组:
var array = arr.filter(Boolean).join('\n').replace(/^\d+\.\s+/gm, '').split('\n');
filter(Boolean)
用于从输入中消除空数组。
<强>输出:强>
[
"Submittals in progress",
"Structural works in progress in S2 & S3",
"Structural works in progress in N4.",
"Childrens Mall pedestal and steel fabrication.",
"Procurement of activities in progress.",
"External works for mist pool in progress",
"MEP 1st & 2nd fix in progress",
"Block work and grade slab in progress "
]
答案 1 :(得分:0)
你需要
这是代码
Windows 10 IoT
答案 2 :(得分:0)
不要长时间使用Code。使用短于&amp;甜蜜的。
var text = [
"1. Submittals in progress\n2. Structural works in progress in S2 & S3\n3. Structural works in progress in N4.\n4. Childrens Mall pedestal and steel fabrication.",
"",
"1. Procurement of activities in progress.\n2. External works for mist pool in progress\n3. MEP 1st & 2nd fix in progress\n4. Block work and grade slab in progress "
];
var rawData = text.join('\n').split('\n').filter(function(index) {
return index !== '' ;
});;
console.log(rawData);
我知道它没有优化但工作正常。
运行此代码&amp;看输出。