[Lazarus] Checking characters in a string

silvioprog silvioprog at gmail.com
Wed Mar 12 15:03:54 CET 2014


2014-03-12 10:53 GMT-03:00 Richard Mace <richard.mace at gmail.com>:

> Hi,
> I am trying to check to make sure the a string contains at least 1
> uppercase character, 1 lowercase character and 1 number.
> Any ideas as of the best way of coding this?
>

In a function, create three Boolean variables (eg. VContainsUpperCase,
VContainsLowerCase, VContainsNumber), make a loop through the string and,
the measure that finding the ocurrences, set the respective variable to
true. Finally, the result will "Result := VContainsUpperCase and
VContainsLowerCase and VContainsNumber".

You can also do this with a set of enums. The function would return the set
itself. If you are interested, I can explain how it would be with the set
too.

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20140312/f88232cc/attachment-0003.html>


More information about the Lazarus mailing list