匹配除字母以外的任何内容 - 正则表达式 [英] Matching anything but a letter - regex

查看:55
本文介绍了匹配除字母以外的任何内容 - 正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何匹配除字母以外的任何内容?我认为 [^a-z]+ 会做但不是真的.

How to match anything BUT a letter? i thought [^a-z]+ will do but not really.

我有这个字符串要搜索:

I have this string to search in:

"price":"7.99","opt":{"1":[1.01,1.02]},"mixedId":0,"price":"8.99","opt":{"3":[1.03],"4":[1.04,1.05]}

我想得到这些值 8.991.04,1.05 但它不能匹配 7.99

I want to get these values 8.99 and 1.04,1.05 but it can't match 7.99

我喜欢这个:

'"price":"(.+?)","opt":\{"[^a-z]*"4":\[(.+?)]'

但它什么也没找到.需要一些支持:)

but it finds nothing. Need some support :)

推荐答案

你固定的 RegEx 应该看起来像这样:

Your fixed RegEx should look something like this:

"price":"([\d\.]+?)","opt":\{"[^az]*"4":\[(.+?)\]

现场演示:http://regex101.com/r/iU3oT7

这篇关于匹配除字母以外的任何内容 - 正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆