<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Thanks Howard,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Your code worked exactly as I expected.</div>
<div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Richard</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On 12 March 2014 16:35, Howard Page-Clark <span dir="ltr"><<a href="mailto:hdpc@talktalk.net" target="_blank">hdpc@talktalk.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">On 12/03/2014 13:53, Richard Mace wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi,<br>
I am trying to check to make sure the a string contains at least 1<br>
uppercase character, 1 lowercase character and 1 number.<br>
Any ideas as of the best way of coding this?<br>
</blockquote>
<br></div>
If you restrict yourself to Latin ansi encoding and 'number' means a numeric digit which does not have to be a whole word, the code is fairly simple since almost no parsing is required. Other cases and encodings require more complex string parsing. For example:<br>
<br>
-- code begin --<br>
<br>
function Valid(const s: string): boolean;<br>
<br>
function HasLowerUpperNumeric: boolean;<br>
var<br>
c: Char;<br>
lower: boolean=False;<br>
upper: boolean=False;<br>
numeric: boolean=False;<br>
begin<br>
Result:=False;<br>
for c in s do begin<br>
if c in ['a'..'z'] then<br>
lower:=True<br>
else if c in ['A'..'Z'] then<br>
upper:=True<br>
else if c in ['0'..'9'] then<br>
numeric:=True;<br>
if lower and upper and numeric then<br>
Exit(True);<br>
end;<br>
end;<br>
<br>
begin<br>
if Length(s) < 3 then<br>
Exit(False);<br>
Result:=HasLowerUpperNumeric;<br>
end;<br>
<br>
-- code end ---<div class="HOEnZb"><div class="h5"><br>
<br>
<br>
--<br>
______________________________<u></u>_________________<br>
Lazarus mailing list<br>
<a href="mailto:Lazarus@lists.lazarus.freepascal.org" target="_blank">Lazarus@lists.lazarus.<u></u>freepascal.org</a><br>
<a href="http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus" target="_blank">http://lists.lazarus.<u></u>freepascal.org/mailman/<u></u>listinfo/lazarus</a><br>
</div></div></blockquote></div><br></div>