Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Trim a sentence in a String Post Reply Post New Topic
Author Message
achandana01
Groupie
Groupie
Avatar

Joined: 20 Jul 2011
Online Status: Offline
Posts: 59
Quote achandana01 Replybullet Topic: Trim a sentence in a String
    Posted: 04 Apr 2012 at 12:03pm
Hi,
 
I do have the strings
 
city new york
Los Angeles
city San Francisco
 
I would like to trim prefix "city" for strings which has city as theirt prefix and leave rest like they are
 
Finally data should look like this
 
new york
Los Angeles
San Francisco
 
Thanks
chand
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 09 Apr 2012 at 8:19am
formula:

If left({city_field},4) ="city" then right({city_field},len({city_field})-5)
else {city_field}

Not tested, but should work.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 09 Apr 2012 at 11:22am
been answered, but how bout this..
 
if left({table.field}, 4 ) = "city " then
  mid ({table.field}, 6)
else
 {table.field}
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 10 Apr 2012 at 4:27am
I always thought you had to have a length with the mid statement (or is that just for old BASIC code).
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 10 Apr 2012 at 4:43am

I know length is optional in Crystal, in fact the only thing I know of where you need to declare the length/number of characters for mid is Excel, and even then you can get round it by entering a high amount of characters

- eg =mid(a1,3,9999).
 
Regards,
Ryan.


Edited by rkrowland - 10 Apr 2012 at 4:53am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 10 Apr 2012 at 7:44am
even old BASIC, you just needed the starting point...at least from vb3 or so on....maybe even QB4
.Net is the same way...if you don't specify length, it is everything from the start to the end of the string.
 
TSQL wants a length, but you use the same trick the rkrowland said...just put in a large value.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 10 Apr 2012 at 11:36am
When I mean old BASIC, I am talking Apple II, Commodore 64 days. :-)
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.