use strict;
my $str = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><div><font face="Arial" color="#000000" size="2">***** Reply to this email to append information to [[WO#17561]] *****<br><br>WO# 17561 was amended to include the following information:<br><br>Thank you for contacting us.<br><br><br>We have received your request and will respond within 2 business days.<br><br><br>Your request number is: REQ-20665.<br><br><br>If you would like to speak with a representative, please contact us at 1 855 242-4492 and reference your request number.<br><br><br>Our hours of operation are Monday to Friday, 8:00 am to 5:00 pm AST.<br><br><br>Thank you for your continued business with Bell Aliant.<br><br><br>Client Services<br>Bell Business Markets<br><br><br><br><br><br><br><br>Legal | Privacy | bell.ca <br><br>Corporate Secretary’s Office of Bell Canada, Bell TV, Bell Mobility, Bell Media and Bell Aliant<br>1 carrefour Alexander-Graham-Bell, Building A-7, Verdun, Quebec, H3E 3B3 <br><br><br><br>© Bell Canada, 2020. All rights reserved.<br><br><br><br><br>[serviceOrderId:bsd_REQ-20665] <br><br>Merci de nous avoir contacté.<br><br><br>Nous avons bien reçu votre demande et nous y réponderons dans 2 jours ouvrables.<br><br><br>Votre numéro de demande est : REQ-20665.<br><br><br>Si vous souhaitez parler à un conseiller, veuillez composer le 1 855 242-4492 et faire référence à votre numéro de demande.<br><br><br>Nos heures d\'ouverture sont de 8 h à 17 h AST, du lundi au vendredi.<br><br><br>Merci de votre fidélité envers Bell Aliant.<br><br><br>Services clients<br>Bell Marché Affaires<br><br><br><br><br><br><br><br>Avis juridiques | Sécurité | bell.ca <br><br>Bureau du secrétaire de Bell Canada, Bell Télé, Bell Mobilité, Bell Média et Bell Aliant<br>1, carrefour Alexander-Graham-Bell, Aile A-7, Verdun (Québec) H3E 3B3 <br><br><br><br>© Bell Canada, 2020. Tous droits réservés.<br><br><br><br><br>[serviceOrderId:bsd_REQ-20665]<br><br></font></div><hr> <span style="font-size: 12px;"><font color="blue"><em><strong>External Email:</strong> Please use caution when opening links and attachments / </em></font></span><em> <span style="font-size: 12px;"><font color="blue"><strong>Courriel externe:</strong> Soyez prudent avec les liens et documents joints </font></span></em></body></html>';
my $regex = qr/\[serviceOrderId:(?<oc_request_id>.[^]]*)\]/ip;
if ( $str =~ /$regex/ ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html