• Status: Solved
• Priority: Medium
• Security: Public
• Views: 140

# Processing a text line

I need to process a line of text using a function that accepts a line of text as a parameter and returns a new processed line of text as a return value. eg.
TextInput                               TextOutput
'45Hello ?there'                     ' Hello there'
0
dargie
• 4
1 Solution

Commented:
I'm not sure what you mean... You can not do that unless you use Pascal... If you think I misunderstood your question, please support some more info, and a more detailed explanation...

10x

Cheers,
Viktor
0

Commented:
Do you mean you want a function that strip all the non-alpha characters (except space) from a string? Below may be a solution:

function myStrProc(InputStr:string);

var
OutputStr:string;
i:integer;
begin

OutputStr:=InputStr;
i:=1;
while  i<=length(OutputStr) do
begin
if ((Ord(OutputStr[i])>=65) and (Ord(OutputStr[i])<=90) or (Ord(OutputStr[i])>=97) and (Ord(OutputStr[i])<=122) or (Ord(OutputStr[i])=32))then
i:=i+1
else
Delete(OutputStr,i,1);
end;
result:OutputStr;
end;

0

Commented:
Oh is that what he wnats....here issomething,,,,,

procedure RemoveJunk(var str : string);
var
i : integer;
begin
for i := 1 to Length(str) do begin
if str[i] in ['~','1','2','3','4','5','6','7','8','9','0','-','=','+','_','<','>',',','.','/','?','.',''','"',';',':',']','}','[','{','|','\','`'] then
Delete(str, i-1, 1);
end;
end;

Cheers,
Viktor
0

Commented:
also include the numbers....

if str[i] in ['0'..'9'] then
...
0

Commented:
or here is a simpler...way yo do all that....

procedure RemoveJunk(var str : string);
var
i : integer;
begin
for i := 1 to Length(str) do
if not str[i] in ['a'..'z', 'A'..'Z'] then Delete(str, i, 1); ;
end;

Cheers,
Viktor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.