Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Processing a text line

Posted on 1998-11-08
5
Medium Priority
?
138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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