开发者

Regex to match ini value

I'm trying to match the last name of a value of an ini line.

foo.bar.far.boo = "some value"

I can match 'boo =' but I just need 'boo'

I do (\w+)\s*= but it matches the equ开发者_运维问答al signs, but I don't want it to be matched.

By the way, I should be able to get if there is no sub values like :

foo = "value"


Use

\w+(?=\s*=)

(?=...) is a positive lookahead assertion, meaning "assert that the enclosed regex can be matched here, but don't make it part of the match itself".

So the regex matches one or more alphanumeric characters if and only if they are followed by (optional whitespace and) an equals sign.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜