8 个解决方案
#1
(?i)(?<=\[)(.*)(?=\])
#2
string input1 = @"[A[B[C]]]";
string pattern = @"(?i)(?<=\[)(.*)(?=\])";
string replacement = ".";
Regex rgx = new Regex(pattern);
string mvalue = rgx.Match(input1).Value;//A[B[C]]
#3
我试了下,楼上方法可以使用。
请帮我看看
"[
[
[4,意大利甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
[
[4,西班牙甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
]
"
这个数据字符串, 如何使用正则表达式获得去除最外层[]的数据
请帮我看看
"[
[
[4,意大利甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
[
[4,西班牙甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
]
"
这个数据字符串, 如何使用正则表达式获得去除最外层[]的数据
#4
问下 string pattern = @"(?i)(?<=\[)(.*)(?=\])";中的(?i)是什么意思?
#5
(?i)不区分大小写,
要替换吗?直接取出来不就行了,正则改成
string pattern = @"(?is)(?<=\[)(.*)(?=\])";//(?is)表示不区分大小写,单行模式
#6
替换
string srw="你的字符串";
string pattern = @"(?is)(\[)?(.*)(\])";
string replacement = "$2";
Regex rgx = new Regex(pattern);
string mystring = rgx.Replace(srw, replacement);
#7
@"\[\w[\w[\w]]+\]"
#8
这个吧
#1
(?i)(?<=\[)(.*)(?=\])
#2
string input1 = @"[A[B[C]]]";
string pattern = @"(?i)(?<=\[)(.*)(?=\])";
string replacement = ".";
Regex rgx = new Regex(pattern);
string mvalue = rgx.Match(input1).Value;//A[B[C]]
#3
我试了下,楼上方法可以使用。
请帮我看看
"[
[
[4,意大利甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
[
[4,西班牙甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
]
"
这个数据字符串, 如何使用正则表达式获得去除最外层[]的数据
请帮我看看
"[
[
[4,意大利甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
[
[4,西班牙甲组联赛,0],
[
[962845,'卡利亚里','切辛线] ,
[0,1,0,1],
[0,0,1,32,45]
],
[0,
[
[9944097,1,40000.00],
[9,10850876,'1.81','0.45','1.50']
]
]
]
]
"
这个数据字符串, 如何使用正则表达式获得去除最外层[]的数据
#4
问下 string pattern = @"(?i)(?<=\[)(.*)(?=\])";中的(?i)是什么意思?
#5
(?i)不区分大小写,
要替换吗?直接取出来不就行了,正则改成
string pattern = @"(?is)(?<=\[)(.*)(?=\])";//(?is)表示不区分大小写,单行模式
#6
替换
string srw="你的字符串";
string pattern = @"(?is)(\[)?(.*)(\])";
string replacement = "$2";
Regex rgx = new Regex(pattern);
string mystring = rgx.Replace(srw, replacement);
#7
@"\[\w[\w[\w]]+\]"
#8
这个吧