|
Post by flotul on Sept 14, 2022 10:42:38 GMT -5
Hi there,
While
String$ = " 1, 2, 3"
String$ = replstr$(String$, " ", "")
print String$
results as: "1,2,3" (correct)
String$ = " 1, 2, 3"
String$ = TRIM$(String$)
print String$
results as: " 1, 2, 3" (incorrect)
Am I using/understanding TRIM$ a wrong way?
|
|
|
Post by flotul on Sept 14, 2022 11:03:34 GMT -5
Humm... just got it.
TRIM$() removes spaces at the beginning and at the end of the string only.
But why does replstr$ not accept to replace spaces by "nothing"?
What is the best way to remove any spaces within a full string then?
|
|
|
Post by xxgeek on Sept 14, 2022 12:00:43 GMT -5
From the help file REMCHAR$( source$, charSet$ ) Description: This function returns a copy of source$ but with all the characters in charSet$ filtered out. Usage: print remchar$("thze emerjgenczy broawdcast sysztem", "zjw") produces: the emergency broadcast system Or for your purpose....
testString$ = "This is a test of the emergency space removal system" print remchar$(testString$, " ") 'or print remchar$("This is a test of the emergency space removal system", " ")
|
|
|
Post by Brandon Parker on Sept 14, 2022 19:01:02 GMT -5
But why does replstr$ not accept to replace spaces by "nothing"? I am not sure I quite follow... Your initial post showed code that replaces " " with "" (i.e. space with nothing), and it produces correct results. Am I misunderstanding? {:0) Brandon Parker
|
|
|
Post by flotul on Sept 17, 2022 5:18:19 GMT -5
But why does replstr$ not accept to replace spaces by "nothing"? I am not sure I quite follow... Your initial post showed code that replaces " " with "" (i.e. space with nothing), and it produces correct results. Am I misunderstanding? {:0) Brandon Parker Sorry for the confusion, Brandon. The answer is yes and no. Yes because TRIM$() does remove leading and trailing spaces of a sting which I didn't got at a first glance. Still, TRIM$() doesn't remove spaces inside the string which I'm currently looking for.
|
|
|
Post by flotul on Sept 17, 2022 5:33:28 GMT -5
From the help file REMCHAR$( source$, charSet$ ) Description: This function returns a copy of source$ but with all the characters in charSet$ filtered out. Usage: print remchar$("thze emerjgenczy broawdcast sysztem", "zjw") produces: the emergency broadcast system Or for your purpose....
testString$ = "This is a test of the emergency space removal system" print remchar$(testString$, " ") 'or print remchar$("This is a test of the emergency space removal system", " ")
Thanks xxgeek,
remchar$() will do perfectly!!!
Thanks a lot again ;-)
|
|
|
Post by tsh73 on Sept 17, 2022 6:15:31 GMT -5
iMHO Really, for contigency case - all functions should work the same way (regardless of case)
|
|
|
Post by Brandon Parker on Sept 18, 2022 8:00:47 GMT -5
I am not sure I quite follow... Your initial post showed code that replaces " " with "" (i.e. space with nothing), and it produces correct results. Am I misunderstanding? {:0) Brandon Parker Sorry for the confusion, Brandon. The answer is yes and no. Yes because TRIM$() does remove leading and trailing spaces of a sting which I didn't got at a first glance. Still, TRIM$() doesn't remove spaces inside the string which I'm currently looking for. Yes, but the statement I am questioning is NOT about Trim$(); it is about the statement you made about ReplStr$() not being able to replace a space with nothing when it is fully capable of doing so. But why does replstr$ not accept to replace spaces by "nothing"? {:0) Brandon Parker
|
|