取以某字符开始,以某字符结束的字符串(正则表达式:VB.net)
要求:解析字符串并取值
DimstrAsString="[11k中国f334][22dfsk文字f3][3333][44ffffff]"
①确认字符串的格式为四个连续的"[]"组成
②格式正确的话,取"[]"中间的值
ImportsSystem.Text.RegularExpressions''''''取以某字符开始,以某字符结束的字符串(正则表达式:VB.net)''''''ModuleModule1SubMain()'StringtoCheckDimstrAsString="[11k中国f334][22dfsk文字f3][3333][44ffffff]"'CheckFormatDimmcFormatCheckAsMatchCollection=Regex.Matches(str,"((\[)([^\[\]]+)(\])){4}")'ifMatchIfmcFormatCheck.Count=1Then'Getthecontentbetween[and]DimmcAsMatchCollection=Regex.Matches(str,"((\[)(.+?)(\]))")ForiAsInteger=0Tomc.Count-1'OutputtheitemswhickismatchedConsole.WriteLine(i.ToString()+":"+mc.Item(i).Value)NextEndIfDimcAsString=Console.ReadLine()EndSubEndModule
相关推荐
wangzhaotongalex 2020-10-20
wyq 2020-11-11
TLROJE 2020-10-26
风雨断肠人 2020-10-13
duanqingfeng 2020-09-29
rechanel 2020-11-16
cshanzhizi 2020-10-16
luofuIT成长记录 2020-09-22
phphub 2020-09-10
taomengxing 2020-09-07
MaggieRose 2020-08-19
flyingssky 2020-08-18
山水沐光 2020-08-18
jyj00 2020-08-15
AHuqihua 2020-08-09
山水沐光 2020-08-03