VBScript正则表达式查找三管(|),双,单

时间:2013-10-23 18:11:27

标签: regex vb.net vbscript

需要帮助构建检查Triple(|||)和||的VBScript正则表达式和|并输出为 例如: -

Contacts ||| ||Position: |PosH | |Pos Cust ||Name: |Name H | |Name Cust || 

a1:-Contacts,a2:||Position: |PosH | |Pos Cust ||Name: |Name H | |Name Cust || 
b1:-Position:, b2:-Name:
c1:PosH ,c2: ,c3:Pos Cust 

1 个答案:

答案 0 :(得分:1)

只需使用Split():

>> s = "Contacts ||| ||Position: |PosH | |Pos Cust ||Name: |Name H | |Name Cust ||"
>> a = Split(s, "|")
>> For i = 0 To UBound(a)
>>     WScript.Echo i, """" & a(i) & """"
>> Next
>>
0 "Contacts "
1 ""
2 ""
3 " "
4 ""
5 "Position: "
6 "PosH "
7 " "
8 "Pos Cust "
9 ""
10 "Name: "
11 "Name H "
12 " "
13 "Name Cust "
14 ""
15 ""
>> WScript.Echo "a1", """" & a(0) & """"
>> WScript.Echo "c3", """" & a(8) & """"
>>
a1 "Contacts "
c3 "Pos Cust "
>>

(并抛出一些Trim()s)