Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Remove hyphen and commas etc Post Reply Post New Topic
Author Message
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet Topic: Remove hyphen and commas etc
    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...:)

IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet 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.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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;
IP IP Logged
jbalbo
Senior Member
Senior Member
Avatar

Joined: 17 Feb 2011
Online Status: Offline
Posts: 219
Quote jbalbo Replybullet 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
 

 
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.