Print Page | Close Window

Getting Charaters after "_"

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19852
Printed Date: 03 May 2024 at 8:46pm


Topic: Getting Charaters after "_"
Posted By: Tompong
Subject: Getting Charaters after "_"
Date 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



Replies:
Posted By: DBlank
Date 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)


Posted By: hilfy
Date 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


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: Tompong
Date Posted: 02 Aug 2013 at 11:00am
works perfectly.

Thanks



Print Page | Close Window