ignore until you find [ read in buffer until you find [ or ] if you found ] the buffer is your result if you found [ reset buffer {optional - if you reach the end and there's no ], scream "betrayal!"} #### $input = ...your text here...; $result = /.*\[(.*^[)\].*/;