ASP正则表达式技巧
日期:08-01  来源:
中国设计秀 作者:cnwebshow.com
RoH中国设计秀
正负预查 RoH中国设计秀
1 #正负预查 2 puts "正负预查" 3 s1 = "New World Dictionary" 4 s2 = "New World Symphony" 5 s3 = "New World Order" 6 7 reg = /New World (?=Dictionary|Symphony)/ 8 m1 = reg.match(s1) 9 puts m1.to_a[0] # "New World"10 m2 = reg.match(s2)11 puts m2.to_a[0] # "New World"12 puts reg.match(s3) # nil13 14 puts "负预查"15 16 reg = /New World (?!Symphony)/ # "New World "后面没有“Symphony”17 puts reg.match(s1).to_a[0] # "New World"18 puts reg.match(s2).to_a[0] # nil19 puts reg.match(s3).to_a[0] # "New World"RoH中国设计秀