求助正则

森小鹿. 2019-09-07 03:34:47
请问下一个字符串 。?![288282]!'@;[[7272],,,,[27]],可以理解为就是个json数据, 我想取出第一个大括号的值288282和后面大括号的值7272 27,但是后面大括号中大括号可能有多个,这个正则怎么写啊
...全文
59 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
knightshou 2019-09-07
  • 打赏
  • 举报
回复
PS C:\WINDOWS\system32> $str = "。?![288282]!'@;[[7272],,,,[27]]" $regex = "\d+" $res = $str | Select-String -Pattern $regex -AllMatches $res.Matches.Value 288282 7272 27 我觉得你要这个, 带入方括号,再处理 PS C:\WINDOWS\system32> $str = "。?![288282]!'@;[[7272],,,,[27]]" $regex = "\[\d+\]" $res = $str | Select-String -Pattern $regex -AllMatches $res.Matches.Value [288282] [7272] [27] 因为我觉得你会需要排除,以下情况。 最后的27你不想要吧 没有排除 PS C:\WINDOWS\system32> $str = "。?![288282]!'@;[[7272],,,,[27" $regex = "\d+" $res = $str | Select-String -Pattern $regex -AllMatches $res.Matches.Value 288282 7272 27 排除27 PS C:\WINDOWS\system32> $str = "。?![288282]!'@;[[7272],,,,[27" $regex = "\[\d+\]" $res = $str | Select-String -Pattern $regex -AllMatches $res.Matches.Value [288282] [7272]

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧