php - Regex - matching all between second set of brackets ([]) -
i have following string need match last 7 digets between [] brackets. string looks
[15211z: 2012-09-12] ([5202900])
i need match 5202900 in string contained between ([]), similar number appear anywhere in string won't work (\d{7})
i tried following regex
([[0-9]{1,7}])
but includes [] in string?
if want 7 digits, not brackets, want make sure digits surrounded brackets:
(?<=\[)\d{7}(?=\]) fyi: called positive lookahead , positive lookbehind.
good source on topic: http://www.regular-expressions.info/lookaround.html
Comments
Post a Comment