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

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -