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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Remove carriage return and extra spaces from string 1

Status
Not open for further replies.

DarthGAD

IS-IT--Management
Mar 17, 2004
37
US
I need to remove any carriage returns ChrW(13) and extra spaces ChrW(10) from a String.

EXAMPLE:
Hello,

This is a nice day to fly a kite.

Bye.

DESIRED OUTCOME:
Hello, this is a nice day to fly a kite. Bye.

I can think of several ways of looping through the text but I am hoping someone else has done this already and can provide a formula.

Thanks

GusDarino
 
You can create a formula using the Replace function multiple times:

Replace(Replace({Table.Field}, Chr(13),""),Chr(10),"")

-dave
 
Dave handled the carriage returns, but if you have extra spaces, you'll need to use something like:

replace({table.field}," "," ")

Noe that this replaces 2 spaces with 1, if there are multiple spaces, you'll need to wrap a few together.

Also your intent demonstrates the need to change uppercase to lower case, as in the word This.

To do so will be a bit trickier as you may need to loop through the string and test every character for it being the first word after an appropriate punctuation for an uppercase.

The version of Crystal will change that part of the solution, so post basic information.

-k
 
Vidru:

This was simple and efficient. It did mainly what I needed it to do. Thanks,

GusDarino
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top