use strict;
my $str = '1000000128 - WhereClause=(@HousingReferral@ = 1 AND Service.FormID= 1000000139) OR @HousingReferral@ =\'\' OR (@HousingReferral@ = 1 AND ServiceReferral.ServiceCodeID = 360 AND Service.FormID IS NULL)&SqlExpression=ISNULL(Service.FormID,1127)
1000000234 - WhereClause=(@HousingReferral@ = 1 AND Service.FormID= 1000000139) OR @HousingReferral@ =\'\' OR (@HousingReferral@ = 1 AND ServiceReferral.ServiceCodeID = 360)&SqlExpression=ISNULL(Service.FormID,1127)
1000000235 - SqlExpression=ISNULL(Service.FormID,1127)&WhereClause=(@HousingReferral@ = 1 AND Service.FormID= 1000000139) OR @HousingReferral@ =\'\' OR (@HousingReferral@ = 1 AND ServiceReferral.ServiceCodeID = 360 AND Service.FormID IS NULL)
1000001453 - WhereClause= ((@HousingReferral@ = 1 AND Service.FormID IN( 1000000139,1E9+431)) OR @HousingReferral@ =\'\' OR (@HousingReferral@ = 1 AND ServiceReferral.ServiceCodeID IN (360,725,726,727,728,729,730) AND Service.FormID IS NULL) OR (ServiceCode.CoordinatedEntryEvent IS NOT NULL OR ServiceCode.CoordinatedEntryEvent IS NOT NULL ))&SqlExpression=ISNULL(Service.FormID,1127)
1000001482 - SearchOnly=1&WhereClause=ServiceCode.ServiceCodeID IN (738,739,742) AND CEEventResult.ReferralResult IS NULL
1000001488 - SearchOnly=1&WhereClause=CEAssessmentLink.PrioritizationStatus = 1 AND Enrollment_Open.ProgramID = 21003
1000001506 - NoSearch=1&Alignment=center&SqlExpression= (SELECT CASE WHEN ReferralServiceCode.ServiceCodeID = 749 THEN 728 WHEN ReferralServiceCode.ServiceCodeID IN (748,750) THEN 729 ELSE ISNULL(ReferralServiceCode.ServiceCodeID,ServiceCode.ServiceCodeID) END AS ServiceCode)
1000001567 - WhereClause=(@HousingReferral@ = 1 AND Service.FormID IN( 1000000139,1E9+431)) OR @HousingReferral@ =\'\' OR (@HousingReferral@ = 1 AND ServiceReferral.ServiceCodeID IN (360,725,726,727,728,729,730) AND Service.FormID IS NULL) &SqlExpression=ISNULL(Service.FormID,1127)
1000001579 - SearchOnly=1&WhereClause=CEAssessmentLink.PrioritizationStatus = 1 AND Enrollment_Open.ProgramID = 21003
1000001586 - SearchOnly=1&WhereClause=CEAssessmentLink.PrioritizationStatus = 1 AND Enrollment_Open.ProgramID = 21003';
my $regex = qr/((ServiceCodeID\s*=\s*[^\s@a-z][0-9]{1,})|(ServiceCodeID\s*in\s*\(\s*[0-9\,*]{1,}\s*\)))|((ProgramID\s*=\s*[^\s@a-z][0-9]{1,})|(ProgramID\s*in\s*\(\s*[0-9\,*]{1,}\s*\)))/mip;
if ( $str =~ /$regex/g ) {
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