开发者

Match individual instances using RegEx

开发者 https://www.devze.com 2023-03-21 04:02 出处:网络
I\'ll be brief \"Test(this)thingplease(for)me\"[/\\(.*\\)/] matches Test (this)thingplease(for) me I want

I'll be brief

"Test(this)thingplease(for)me"[/\(.*\)/]

matches

Test (this)thingplease(for) me

I want

Test (this) thing开发者_如何学JAVAplease (for) me


Use non greedy regex, i.e.: \(.*?\) or this: \([^()]*\)

It will match:

  1. (this)
  2. (for)


Try making the match non-greedy by adding a ? after the *:

/\(.*?\)/

Otherwise try

/\([^)]*\)/

0

精彩评论

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