/\[\s* # literal [ followed by optional whitespace ( # begin capture [^\]]+ # get one or more chars that are not ] ) # end capture /x # end regex