开发者

matching regex of a particular form

开发者 https://www.devze.com 2023-02-18 02:10 出处:网络
I want to match a regex of the following form (hex_number) (anything) constant=(true or开发者_如何学C false)

I want to match a regex of the following form

(hex_number) (anything) constant=(true or开发者_如何学C false)

anything can match any printable character or a space or tab. I am programming in java so I was using the following regex:

(\\p{Alnum}+) (\\.+) constant=(true|false)

The first two matching groups is what I really want. I however do not get a match.

Any ideas?

PS: Alnum and . are just for simplicity and it is fine that they will match more than what I require.


Edit: Can't believe I missed this the first time. You want ., not \\.. Your version matches a literal . character.

([0-9A-Fa-f]+)\\s(.+)\\sconstant=(true|false)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号