Print Page | Close Window

Remove hyphen and commas etc

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16038
Printed Date: 28 Apr 2024 at 2:35pm


Topic: Remove hyphen and commas etc
Posted By: jbalbo
Subject: Remove hyphen and commas etc
Date Posted: 29 Mar 2012 at 6:45am
How can I remove characters froma name field?
example O'Donnell,  I want as ODonnell
Smith_Martin as SmithMartin

Thanks Again...:)




Replies:
Posted By: kevlray
Date Posted: 29 Mar 2012 at 7:56am
I believe the replace command should work.  Of course you would need a separate replace for each character needing removal.

local stringvar Name := {name_field};
Name := replace(Name,"_","");
Name := replace(Name,"'","");

etc.  Not sure if you need to put in a double single quote to remove one quote.  That would take some testing.


Posted By: DBlank
Date Posted: 29 Mar 2012 at 8:08am
also found this from another site
 
//construct an array of alpha characters.
StringVar Array
legalchar:=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R",
"S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p",
"q","r","s","t","u","v","w","x","y","z"];
StringVar LSt:= {TABLE.FIELD};
StringVar RSt:= "";
Local NumberVar i;
// Parses the string and removes non-alpha characters
For i := 1 to length(Lst) Do
If LSt in legalchar then
Rst:= Rst + Lst
Else Rst := Rst;
//Returns the new string
Rst;


Posted By: jbalbo
Date Posted: 29 Mar 2012 at 8:31am
Thank you both,
I have tried
local stringvar Name := {name_field};
Name := replace(Name,"_","");
Name := replace(Name,"'","");
and it works,
The other one I'm still trying, I'm getting blank names, but it does seem better because it accounts for anything except a letter...
I'll get back when I find something...
 
Thanks again
Joe
 

 



Print Page | Close Window