I want to thank I0 for correcting some bugs:
-
'[' is apparently a reserved character in Perl REs so it needed to be escaped.
- The ? in .*? turns off greedy matching. Thus everything after id= will be matched but only up until the first '[' it encounters.