Link to home
Start Free TrialLog in
Avatar of Stef Merlijn
Stef MerlijnFlag for Netherlands

asked on

Quickly scan string if it contains certain characters

Hi,

I need to check if a string contains following characters/tokens (between the single qoutes).
'*','"','/','\','<','>','?',':','|' Ā  (these are the characters/tokens that aren't allowed in filenames).

For entering individual characters in the editfield I use the function below in the OnKeyPress-event. But when a user paste a string into the editfield, this event isn't fired. Therefor I want to check the inserted string afterwards.

Can anybody supply me with a fast function that will do the trick? Or maybe a better solution is possible?
Regards, Stef
function GeldigTekenBestandsnaam(var Key : Char) : Boolean;
begin
  Result := True;
  If (key in ['*','"','/','\','<','>','?',':','|']) then
    Result := False;
end;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Lukasz Zielinski
Lukasz Zielinski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
... make it a function and use in edit's OnChange event handler

ziolko.
Avatar of Stef Merlijn

ASKER

Perfect.