Solved

Processing a text line

Posted on 1998-11-08
5
133 Views
Last Modified: 2010-04-04
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
Comment
Question by:dargie
  • 4
5 Comments
 
LVL 10

Expert Comment

by:viktornet
ID: 1346089
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
 
LVL 4

Accepted Solution

by:
dwwang earned 50 total points
ID: 1346090
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1346091
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1346092
also include the numbers....

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

Expert Comment

by:viktornet
ID: 1346093
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

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question