Txt-Remove chars not in list

From Vectorlab
Jump to: navigation, search


Function to remove all characters in as string that are not contained in a dynarray of char. Returns the modified string. By Orso B. Schmid


{ Orso *********************************************** }
{ removes from a string chars not in array. }
{ list will be converted to dinarray of char, can be a normal string }
FUNCTION T_RemoveNotInList(str: STRING; list: DYNARRAY[] OF CHAR): STRING;
	VAR
		i : INTEGER;
		
	BEGIN
		i := 1;
		WHILE i <= Len(str) DO
			IF (Pos(Copy(str, i, 1), list) = 0) THEN
				Delete(str, i, 1)
			ELSE
				i := i + 1;
		
		T_RemoveNotInList := str;
	END;