This is a bit peculiar, but the application that I'm using only implements a limited subset of Regular Expression parameters. Most significantly, it doesn't support ANY group options other than basic parenthesis grouping ( i.e. no named groups, no look-aheads, or look-behinds, not even (?:)
).
I'm only looking to get a TRUE
/FALSE
match, I don't need to extract, replace or parse the data, I just need to know if the specified pattern occurs in the subject string, yes or no.
So I'm trying to build out a pattern using basic Regex that will trigger a match upon finding 3 of 4 provided terms, from a block of text, and which may be in any order.
To wit, I tried this: (\b(Term1|Term2|Term3|Term4)\b.*?){3,}
but it doesn't work. Weirdly, if I change {3,}
to {1,}
it finds all instances of every term, indicating that the pattern DOES work, but when I tell it I only want a match if there are 3 or more instances, it doesn't find any of them. This remains true even when I try the pattern on Regex101, so it doesn't seem to be a failure of the limited engine within my app.
All of the words in the subject text are preceded and followed by at least one space, or a period and do report matches when the pattern /b(TermX)/b
is used. In one piece of sample data, when the quantifier is converted to {1,}
9 matches are found, but when changed to {3,}
ZERO are!
What am I missing / misunderstanding about this pattern?
Edit: Going back to the limited feature-set that I'm dealing with: I am only able to specify the pattern. As far as I can tell, there is no provided mechanism for specifying the conditions (i.e. Case Insensitive, Global, MultiLine, SingleLine etc.) and it appears that none of them are set by default.
Edit: Sample data, by request...
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body>
<p><span style="text-decoration: underline;"><strong>EXPIRATION
NOTIFICATION FOR</strong></span><br>somedomain.com</p>
<p>Your domain service account is pending cancellation.</p>
<p></p>
<p>Notice#: xxx-xxx<br>Date: 04.24.2019<br>EXPIRATION DATE:
05.02.2019</p>
<p></p>
<p><b>Follow up on:<br></b><b><span style="text-decoration:
underline;"><span style="color: #ff6600;"><a href="https://spamurl.com"><span style="color: #ff6600; text-decoration: underline;">Secure Online
Payment</span></a></span></span><br></b><b>to complete.</b></p>
<p></p>
<p>Domain: somedomain.com<br>Registration Period: 1 Year/s<br>Amount:
$86.00 USD<br>Status: Pending (Unpaid)</p>
<p></p>
<p></p>
<p>Dear Name Lastname|CompanyName, ,<br>We are reaching out
to let you know that your notice #xxx-xxx is 5 days overdue.<br>We
are keeping your service for somedomain.com online, as your are still within
our grace period, and we want ensure the best possible service for
you.</p>
<p>Your account is in danger of being suspended if we do not receive your
payment soon. Please pay your notice here to avoid service
disruption. </p>
<p></p>
<p><b>Follow up on:<br></b><b><a href="https://spamurl.com"><span style="text-decoration: underline;"><span style="color: #ff6600;"><span style="color: #ff6600; text-decoration: underline;">Secure Online
Payment</span></span></span><br></a></b><b>to complete.</b></p>
<p></p>
<p><span style="font-size: xx-small; color: #c0c0c0;">Instructions and
Unlike Instructions from this Newsletter:</span><br><span style="font-size: xx-small; color: #c0c0c0;">This Email contains
information intended only for the individuals or entities to which it is
addressed. If you are not the intended recipient or the agent responsible
for delivering it to the intended recipient, or have received this Email in
error, please notify immediately the sender of this Email at the Help
Center and then completely delete it. Any other action taken in reliance
upon this Email is strictly prohibited, including but not limited to
unauthorized copying, printing, disclosure, or distribution. We do not
directly register or renew domain names. This is not a bill or an invoice.
This is a optimization offer for your website. You are under no obligation
to pay the amount stated unless you accept this purchase offer. Promotional
material is strictly along the guidelines oft he can-spam act of 2003. They
are in no way misleading. You have received this message because you
elected to receive notification offers. Thank you for your
cooperation. Unsubscribe Domain Service renew <span style="text-decoration: underline;"><a href="https://spamurl.com"><span style="color: #c0c0c0; text-decoration:
underline;">here</span></a></span>.</span></p>
<img src="https://spamurl.com" height="1" width="10"></body>
</html>