Tips and Tricks
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Tips and Tricks
Message Icon Topic: Getting Charaters after "_" Post Reply Post New Topic
Author Message
Tompong
Newbie
Newbie


Joined: 06 Feb 2013
Online Status: Offline
Posts: 11
Quote Tompong Replybullet Topic: Getting Charaters after "_"
    Posted: 01 Aug 2013 at 12:14pm
Can any one help me to get character after "_" Im having a hard time figuring it out.

Thanks

Edited by Tompong - 01 Aug 2013 at 12:15pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Aug 2013 at 4:27am
use instr() to find the location of the character in the string and then mid() to start looking at the field after that.
something like
mid(field,instr(field,"-")+1)
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 02 Aug 2013 at 10:54am
Another way to do it might be to do something like this:
 
StringVar Array sa := split({myTable.myField}, '_');
 
if (uBound(sa) > 1) then  sa[2]
else sa[1]
 
This splits the string into an array of strings based on the location of the '_' character and then returns the second element which should be the string after the '_' character.
 
-Dell
IP IP Logged
Tompong
Newbie
Newbie


Joined: 06 Feb 2013
Online Status: Offline
Posts: 11
Quote Tompong Replybullet Posted: 02 Aug 2013 at 11:00am
works perfectly.

Thanks
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.