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

Trim spaces between backslash & frontslash 1

Status
Not open for further replies.

PandaOracle

Programmer
Feb 27, 2012
13
CA
Was wondering how would I trim the spaces before and after a slash.

EG.

Hello my name is / bob.

-----runs-----

Hello my name is/bob.

*i was thinking of using substring and locating each back slash and then triming the spaces but i was wondering if any verterans know a cleaner solution.
 
stringvar array x := split({table.field},"/");
trim(x[1])+"/"+trim(x[2])

-LB
 
Thank Bass. =D! was able to add a for loop and it works nicely.
 
Why did you need a loop? Did you have recurring instances within the field? Please post your final formula. Thanks.

-LB
 
stringvar array x := split({table.field},"/");

Local NumberVar strLen := count (x);
Local NumberVar i;
local StringVar name := "";
For i := 1 To strLen Do
(

if strlen = i then
(name := name & trim(x));
else
(name := name & trim(x) + "/");
);


name;

there could be X amount of slashes in a name. right now i'm adding the front slash too.
 
If the aim is simply to remove any such excessive spacing then a basic: replace({table.field},' ','') would solve the issue for any form of slash or other symbol and any number of occurences.

This would however not resolve single spaces pre or post such symbols so the answer yourself and LBass have put in place would b very much more effective.

'J

CR8.5 / CRXI - Discovering the impossible
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top