Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Breaking string into list w/ multiple delimiters 1

Status
Not open for further replies.

Buckaroo8

Programmer
Aug 6, 2003
27
US
Hi all,
I asked a similar question last week of how to change a string of items into a list format with delimiters of ';'. The answer which proved to work was:

join(split({Field.SummaryLine},";"),chr(13))

Very Cool, still don't understand the how/why of it, but that's for a later conversation.

The issue is that not only are there ';' characters, but there are also '-' characters as well in the same string. How can I achieve the same list result with two different characters as delimiters?

Thanks much for your help!
 
You could use the Replace() function to change the "-"'s to ";"'s or vice versa:

Replace({Field.SummaryLine},"-",";")

... or if you're using the posted formula:

join(split(Replace({Field.SummaryLine},"-",";"),";"),chr(13))

-dave
 
Hi,
The how is:

First the string is separated into an array with the ';' controlling when an element is complete..The Join command then creates a string from the elements in that new array with the chr(13) between each element.

To have it work with multiple possible delimiters, you would probably need to construct some type of 'regular expression' and use it in place of the explicit delimiter
NOTE: This works for JavaScript, but I am not sure it can be implemented in Crystal's syntax..

[profile]
 
Totally Awesome Dave!
(Forgive my 80's vernacular)

I don't suppose you can walk through how it works?

Thanks again!!!
 
Hi, I agree - Dave got it in one..
Much easier than my attempt.
[profile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top