Print Page | Close Window

Replacing Character in String Once

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=22941
Printed Date: 28 Apr 2024 at 11:56am


Topic: Replacing Character in String Once
Posted By: jsh8286
Subject: Replacing Character in String Once
Date Posted: 28 Jul 2021 at 7:03am
I want to remove a dash ('-') in a string but only one occurrence of it.

For example have a string of:

"MW-48-00-5182"

But I only want to remove the first occurrence of the dash. In all my records I want to remove the dash in position 3 and leave all other dashes alone if there is any. So the end result for the above example would be:

"MW48-00-5182"

Thanks in advance.



Replies:
Posted By: Valert16
Date Posted: 28 Jul 2021 at 7:22am
The "Replace" function can do this work:

Replace("MW-48-00-5182", "-", "", 1, 1)


Posted By: jsh8286
Date Posted: 28 Jul 2021 at 8:24am
Thanks Valert16 worked like a charm!



Print Page | Close Window